Ticket #7206: 7206-2.patch
File 7206-2.patch, 1.6 KB (added by , 16 years ago) |
---|
-
django/core/urlresolvers.py
92 92 Raises NoReverseMatch if the args/kwargs aren't valid for the regex. 93 93 """ 94 94 # 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('\\','') 97 98 98 99 class MatchChecker(object): 99 100 "Class used in reverse RegexURLPattern lookup." -
tests/regressiontests/urlpatterns_reverse/tests.py
24 24 ('^people/(?P<state>\w\w)/(?P<name>\w+)/$', NoReverseMatch, [], {'name': 'adrian'}), 25 25 ('^people/(?P<state>\w\w)/(\w+)/$', NoReverseMatch, ['il'], {'name': 'adrian'}), 26 26 ('^people/(?P<state>\w\w)/(\w+)/$', 'people/il/adrian/', ['adrian'], {'state': 'il'}), 27 ('^test/1/?', 'test/1/', [], {}), 28 ('^(?i)test/2/?$', 'test/2/', [], {}) 27 29 ) 28 30 31 29 32 class URLPatternReverse(unittest.TestCase): 30 33 def test_urlpattern_reverse(self): 31 34 for regex, expected, args, kwargs in test_data: