Fixed #26621 -- Corrected simplify_regex()'s handling of named capture groups.

This commit is contained in:
Ketan Bhatt 2016-05-30 20:44:00 +05:30 committed by Tim Graham
parent fd2f7e4767
commit f0ef0c49e9
3 changed files with 102 additions and 12 deletions

View file

@ -335,6 +335,11 @@ class AdminDocViewFunctionsTests(SimpleTestCase):
(r'^a', '/a'),
(r'^(?P<a>\w+)/b/(?P<c>\w+)/$', '/<a>/b/<c>/'),
(r'^(?P<a>\w+)/b/(?P<c>\w+)$', '/<a>/b/<c>'),
(r'^(?P<a>\w+)/b/(\w+)$', '/<a>/b/<var>'),
(r'^(?P<a>\w+)/b/((x|y)\w+)$', '/<a>/b/<var>'),
(r'^(?P<a>(x|y))/b/(?P<c>\w+)$', '/<a>/b/<c>'),
(r'^(?P<a>(x|y))/b/(?P<c>\w+)ab', '/<a>/b/<c>ab'),
(r'^(?P<a>(x|y)(\(|\)))/b/(?P<c>\w+)ab', '/<a>/b/<c>ab'),
)
for pattern, output in tests:
self.assertEqual(simplify_regex(pattern), output)