Refs #32499 -- Added more tests for simplify_regex().
This commit is contained in:
parent
27189af8cf
commit
9f7809ece3
|
@ -385,7 +385,7 @@ class AdminDocViewFunctionsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_simplify_regex(self):
|
def test_simplify_regex(self):
|
||||||
tests = (
|
tests = (
|
||||||
(r'^a', '/a'),
|
# Named and unnamed groups.
|
||||||
(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/(?P<c>\w+)$', '/<a>/b/<c>'),
|
(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/(?P<c>\w+)', '/<a>/b/<c>'),
|
||||||
|
@ -397,6 +397,17 @@ class AdminDocViewFunctionsTests(SimpleTestCase):
|
||||||
(r'^(?P<a>(x|y))/b/(?P<c>\w+)', '/<a>/b/<c>'),
|
(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'),
|
||||||
(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'),
|
||||||
|
# Single and repeated metacharacters.
|
||||||
|
(r'^a', '/a'),
|
||||||
|
(r'^^a', '/a'),
|
||||||
|
(r'^^^a', '/a'),
|
||||||
|
(r'a$', '/a'),
|
||||||
|
(r'a$$', '/a'),
|
||||||
|
(r'a$$$', '/a'),
|
||||||
|
(r'a?', '/a'),
|
||||||
|
(r'a??', '/a'),
|
||||||
|
(r'a???', '/a'),
|
||||||
|
# Multiple mixed metacharacters.
|
||||||
(r'^a/?$', '/a/'),
|
(r'^a/?$', '/a/'),
|
||||||
)
|
)
|
||||||
for pattern, output in tests:
|
for pattern, output in tests:
|
||||||
|
|
Loading…
Reference in New Issue