diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-04-21 21:54:00 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-05-11 22:02:14 +0200 |
| commit | 70779d9c1cab77791c73b72e8a63f60184d8f2b0 (patch) | |
| tree | 7828e9c41beadca59af894c6191f7825a4387879 /tests | |
| parent | bd53db5eab05099ae371348529c6428e0da95c6a (diff) | |
Fixed #24733 -- Passed the triggering exception to 40x error handlers
Thanks Tim Graham for the review.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 3 | ||||
| -rw-r--r-- | tests/view_tests/tests/test_defaults.py | 14 | ||||
| -rw-r--r-- | tests/view_tests/urls.py | 3 | ||||
| -rw-r--r-- | tests/view_tests/views.py | 2 |
4 files changed, 14 insertions, 8 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index 17c4f6e359..a98b776f78 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -81,7 +81,7 @@ class DebugViewTests(LoggingCaptureMixin, TestCase): 'OPTIONS': { 'loaders': [ ('django.template.loaders.locmem.Loader', { - '403.html': 'This is a test template for a 403 error.', + '403.html': 'This is a test template for a 403 error ({{ exception }}).', }), ], }, @@ -89,6 +89,7 @@ class DebugViewTests(LoggingCaptureMixin, TestCase): def test_403_template(self): response = self.client.get('/raises403/') self.assertContains(response, 'test template', status_code=403) + self.assertContains(response, '(Insufficient Permissions).', status_code=403) def test_404(self): response = self.client.get('/raises404/') diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py index 0f3f4fe014..a729276887 100644 --- a/tests/view_tests/tests/test_defaults.py +++ b/tests/view_tests/tests/test_defaults.py @@ -79,7 +79,8 @@ class DefaultsTests(TestCase): 'OPTIONS': { 'loaders': [ ('django.template.loaders.locmem.Loader', { - '404.html': 'This is a test template for a 404 error.', + '404.html': 'This is a test template for a 404 error ' + '(path: {{ request_path }}, exception: {{ exception }}).', '500.html': 'This is a test template for a 500 error.', }), ], @@ -90,10 +91,13 @@ class DefaultsTests(TestCase): Test that 404.html and 500.html templates are picked by their respective handler. """ - for code, url in ((404, '/non_existing_url/'), (500, '/server_error/')): - response = self.client.get(url) - self.assertContains(response, "test template for a %d error" % code, - status_code=code) + response = self.client.get('/server_error/') + self.assertContains(response, "test template for a 500 error", status_code=500) + response = self.client.get('/no_such_url/') + self.assertContains(response, 'path: /no_such_url/', status_code=404) + self.assertContains(response, 'exception: Resolver404', status_code=404) + response = self.client.get('/technical404/') + self.assertContains(response, 'exception: Testing technical 404.', status_code=404) def test_get_absolute_url_attributes(self): "A model can set attributes on the get_absolute_url method" diff --git a/tests/view_tests/urls.py b/tests/view_tests/urls.py index 1d34b1f934..4215a4b26a 100644 --- a/tests/view_tests/urls.py +++ b/tests/view_tests/urls.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from functools import partial from os import path from django.conf.urls import include, url @@ -57,7 +58,7 @@ urlpatterns = [ url(r'^$', views.index_page), # Default views - url(r'^non_existing_url/', defaults.page_not_found), + url(r'^non_existing_url/', partial(defaults.page_not_found, exception=None)), url(r'^server_error/', defaults.server_error), # a view that raises an exception for the debug view diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py index c4d025c349..7996193b2e 100644 --- a/tests/view_tests/views.py +++ b/tests/view_tests/views.py @@ -52,7 +52,7 @@ def raises400(request): def raises403(request): - raise PermissionDenied + raise PermissionDenied("Insufficient Permissions") def raises404(request): |
