mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-23 23:23:06 +11:00
Fixed missing exception for 404 views in Django 1.9+
This commit is contained in:
parent
12a15fffaf
commit
f6d8c1c742
2 changed files with 10 additions and 11 deletions
|
@ -131,15 +131,11 @@ class SnippetTestCase(TestCase):
|
|||
self.assertEqual(response.status_code, 404)
|
||||
self.assertEqual(Snippet.objects.count(), 0)
|
||||
|
||||
# def test_new_snippet_`_whitespace(self):
|
||||
# # POST data
|
||||
# data = self.valid_form_data(content=' abc')
|
||||
# response = self.client.post(self.new_url, data, follow=True)
|
||||
# self.assertEqual(response.status_code, 200)
|
||||
# self.assertEqual(Snippet.objects.count(), 1)
|
||||
# print(response.content)
|
||||
# self.assertContains(response, ' abc')
|
||||
|
||||
def test_snippet_notfound(self):
|
||||
url = reverse('snippet_details', kwargs={'snippet_id': 'abcd'})
|
||||
response = self.client.get(url, follow=True)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Reply
|
||||
|
|
|
@ -3,6 +3,7 @@ import difflib
|
|||
import json
|
||||
|
||||
from django.conf import settings
|
||||
from django import get_version
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db.models import Count
|
||||
|
@ -292,8 +293,10 @@ def snippet_api(request):
|
|||
# handle them here.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def page_not_found(request, template_name='dpaste/404.html'):
|
||||
return django_page_not_found(request, template_name) # pragma: no cover
|
||||
def page_not_found(request, exception=None, template_name='dpaste/404.html'):
|
||||
if not exception: # Django <1.8
|
||||
return django_page_not_found(request, template_name=template_name)
|
||||
return django_page_not_found(request, exception, template_name=template_name)
|
||||
|
||||
def server_error(request, template_name='dpaste/500.html'):
|
||||
return django_server_error(request, template_name) # pragma: no cover
|
||||
return django_server_error(request, template_name=template_name) # pragma: no cover
|
||||
|
|
Loading…
Reference in a new issue