mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
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]
This commit is contained in:
committed by
Honza Král
parent
8bbdcc76e4
commit
79558c787e
@@ -272,10 +272,10 @@ class ResolverTests(unittest.TestCase):
|
||||
self.fail('resolve did not raise a 404')
|
||||
except Resolver404 as e:
|
||||
# make sure we at least matched the root ('/') url resolver:
|
||||
self.assertTrue('tried' in e.args[0])
|
||||
tried = e.args[0]['tried']
|
||||
self.assertEqual(len(e.args[0]['tried']), len(url_types_names), 'Wrong number of tried URLs returned. Expected %s, got %s.' % (len(url_types_names), len(e.args[0]['tried'])))
|
||||
for tried, expected in zip(e.args[0]['tried'], url_types_names):
|
||||
self.assertTrue(hasattr(e, 'tried'))
|
||||
tried = e.tried
|
||||
self.assertEqual(len(tried), len(url_types_names), 'Wrong number of tried URLs returned. Expected %s, got %s.' % (len(url_types_names), len(tried)))
|
||||
for tried, expected in zip(tried, url_types_names):
|
||||
for t, e in zip(tried, expected):
|
||||
self.assertIsInstance(t, e['type']), str('%s is not an instance of %s') % (t, e['type'])
|
||||
if 'name' in e:
|
||||
|
||||
Reference in New Issue
Block a user