diff --git a/dpaste/tests/test_snippet.py b/dpaste/tests/test_snippet.py index ec4db29..118ef87 100644 --- a/dpaste/tests/test_snippet.py +++ b/dpaste/tests/test_snippet.py @@ -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 diff --git a/dpaste/views.py b/dpaste/views.py index 82e0107..2ceab80 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -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