From 9f7809ece37cc8b5f3239908fbdcebe32606ce2d Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Tue, 6 Jul 2021 22:53:22 +0100 Subject: [PATCH] Refs #32499 -- Added more tests for simplify_regex(). --- tests/admin_docs/test_views.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py index 085b821a37..73426a3f8f 100644 --- a/tests/admin_docs/test_views.py +++ b/tests/admin_docs/test_views.py @@ -385,7 +385,7 @@ class AdminDocViewFunctionsTests(SimpleTestCase): def test_simplify_regex(self): tests = ( - (r'^a', '/a'), + # Named and unnamed groups. (r'^(?P\w+)/b/(?P\w+)/$', '//b//'), (r'^(?P\w+)/b/(?P\w+)$', '//b/'), (r'^(?P\w+)/b/(?P\w+)', '//b/'), @@ -397,6 +397,17 @@ class AdminDocViewFunctionsTests(SimpleTestCase): (r'^(?P(x|y))/b/(?P\w+)', '//b/'), (r'^(?P(x|y))/b/(?P\w+)ab', '//b/ab'), (r'^(?P(x|y)(\(|\)))/b/(?P\w+)ab', '//b/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/'), ) for pattern, output in tests: