Ticket #7206: 7206-2.patch

File 7206-2.patch, 1.6 KB (added by tlpinney, 7 years ago)

Fixes problem with the test failing, adds a couple regression tests

  • django/core/urlresolvers.py

     
    9292    Raises NoReverseMatch if the args/kwargs aren't valid for the regex.
    9393    """
    9494    # TODO: Handle nested parenthesis in the following regex.
    95     result = re.sub(r'\(([^)]+)\)', MatchChecker(args, kwargs), regex.pattern)
    96     return result.replace('^', '').replace('$', '').replace('\\', '')
     95    pattern = re.sub(r'\(\?[iLmsux]+\)','',regex.pattern)
     96    result = re.sub(r'\(([^)]+)\)', MatchChecker(args, kwargs), pattern)
     97    return result.replace('^', '').replace('$', '').replace('?','').replace('\\','')
    9798
    9899class MatchChecker(object):
    99100    "Class used in reverse RegexURLPattern lookup."
  • tests/regressiontests/urlpatterns_reverse/tests.py

     
    2424    ('^people/(?P<state>\w\w)/(?P<name>\w+)/$', NoReverseMatch, [], {'name': 'adrian'}),
    2525    ('^people/(?P<state>\w\w)/(\w+)/$', NoReverseMatch, ['il'], {'name': 'adrian'}),
    2626    ('^people/(?P<state>\w\w)/(\w+)/$', 'people/il/adrian/', ['adrian'], {'state': 'il'}),
     27    ('^test/1/?', 'test/1/', [], {}),
     28    ('^(?i)test/2/?$', 'test/2/', [], {})
    2729)
    2830
     31
    2932class URLPatternReverse(unittest.TestCase):
    3033    def test_urlpattern_reverse(self):
    3134        for regex, expected, args, kwargs in test_data:
Back to Top