Ticket #14027: django-reverse-none.2.diff

File django-reverse-none.2.diff, 1.3 KB (added by Alex Gaynor, 14 years ago)

Apparently widow'd comments are more important than 79 col zealotry :)

  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index cad57a5..8ecec94 100644
    a b class RegexURLResolver(object):  
    183183            else:
    184184                bits = normalize(p_pattern)
    185185                lookups.appendlist(pattern.callback, (bits, p_pattern))
    186                 lookups.appendlist(pattern.name, (bits, p_pattern))
     186                if pattern.name is not None:
     187                    lookups.appendlist(pattern.name, (bits, p_pattern))
    187188        self._reverse_dict = lookups
    188189        self._namespace_dict = namespaces
    189190        self._app_dict = apps
  • tests/regressiontests/urlpatterns_reverse/tests.py

    diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
    index 3fcc935..0108f9f 100644
    a b class URLPatternReverse(TestCase):  
    118118                self.assertEqual(expected, NoReverseMatch)
    119119            else:
    120120                self.assertEquals(got, expected)
     121   
     122    def test_reverse_none(self):
     123        # Reversing None should raise an error, not return the last un-named view.
     124        self.assertRaises(NoReverseMatch, reverse, None)
    121125
    122126class ResolverTests(unittest.TestCase):
    123127    def test_non_regex(self):
Back to Top