summaryrefslogtreecommitdiff
path: root/tests/view_tests
diff options
context:
space:
mode:
authorGrzegorz Nosek <root@localdomain.pl>2014-02-15 14:41:01 +0100
committerHonza Král <honza.kral@gmail.com>2014-02-15 15:56:04 +0100
commit79558c787ebfd0fe723acb061a375b19a27f18cd (patch)
treeb16a9c3ba02a78e3c8750449d8ae141a993b5198 /tests/view_tests
parent8bbdcc76e4a84cde92b8dbfd01581d098bd2187d (diff)
Fixed #18373 - improved handling of Resolver404s from views
When django.core.urlresolvers.resolve was called from a view, failed and the exception was propagated and rendered by technical_404_response, the URL mentioned on the page was the current URL instead of the URL passed to resolve(). Fixed by using the path attribute from the Resolver404 exception instead of request.path_info. Also cleaned up the exceptions to use standard named parameters instead of stuffing a dict in args[0]
Diffstat (limited to 'tests/view_tests')
-rw-r--r--tests/view_tests/tests/test_debug.py8
-rw-r--r--tests/view_tests/views.py2
2 files changed, 9 insertions, 1 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 44e70347bd..b66bdac32d 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -69,6 +69,14 @@ class DebugViewTests(TestCase):
response = self.client.get('/raises404/')
self.assertEqual(response.status_code, 404)
+ def test_raised_404(self):
+ response = self.client.get('/views/raises404/')
+ self.assertContains(response, "<code>not-in-urls</code>, didn't match", status_code=404)
+
+ def test_404_not_in_urls(self):
+ response = self.client.get('/not-in-urls')
+ self.assertContains(response, "<code>not-in-urls</code>, didn't match", status_code=404)
+
def test_view_exceptions(self):
for n in range(len(except_args)):
self.assertRaises(BrokenException, self.client.get,
diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py
index e0f6fdb753..2e8a270e94 100644
--- a/tests/view_tests/views.py
+++ b/tests/view_tests/views.py
@@ -57,7 +57,7 @@ def raises403(request):
def raises404(request):
resolver = get_resolver(None)
- resolver.resolve('')
+ resolver.resolve('/not-in-urls')
def redirect(request):