Commit f90a2555 authored by Russell Keith-Magee's avatar Russell Keith-Magee
Browse files

Fixed #14027 -- Ensure that reverse() raises an exception when you try to...

Fixed #14027 -- Ensure that reverse() raises an exception when you try to reverse None. Thanks to Alex for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13499 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent d3ba8cb8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ class RegexURLResolver(object):
            else:
                bits = normalize(p_pattern)
                lookups.appendlist(pattern.callback, (bits, p_pattern))
                if pattern.name is not None:
                    lookups.appendlist(pattern.name, (bits, p_pattern))
        self._reverse_dict = lookups
        self._namespace_dict = namespaces
+4 −0
Original line number Diff line number Diff line
@@ -154,6 +154,10 @@ class URLPatternReverse(TestCase):
            else:
                self.assertEquals(got, expected)

    def test_reverse_none(self):
        # Reversing None should raise an error, not return the last un-named view.
        self.assertRaises(NoReverseMatch, reverse, None)

class ResolverTests(unittest.TestCase):
    def test_non_regex(self):
        """