1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #17076 -- When reversing a URL fails, inform the user which patterns were tried.

This commit is contained in:
Wilfred Hughes
2013-06-13 13:55:18 +01:00
committed by Marc Tamlyn
parent 0f3f88ec94
commit 8365ed08b8
2 changed files with 18 additions and 1 deletions

View File

@@ -192,6 +192,20 @@ class URLPatternReverse(TestCase):
self.assertEqual('/%7Eme/places/1/',
reverse('places', args=[1], prefix='/~me/'))
def test_patterns_reported(self):
# Regression for #17076
try:
# this url exists, but requires an argument
reverse("people", args=[])
except NoReverseMatch as e:
pattern_description = r"1 pattern(s) tried: ['people/(?P<name>\\w+)/$']"
self.assertIn(pattern_description, str(e))
else:
# we can't use .assertRaises, since we want to inspect the
# exception
self.fail("Expected a NoReverseMatch, but none occurred.")
class ResolverTests(unittest.TestCase):
def test_resolver_repr(self):
"""