summaryrefslogtreecommitdiff
path: root/tests/admin_docs
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2021-07-06 22:53:22 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-22 11:59:59 +0200
commit9f7809ece37cc8b5f3239908fbdcebe32606ce2d (patch)
treea372c525baaca6fef8d4571443eb1588614e884f /tests/admin_docs
parent27189af8cf2760e6aaf10ca1aa77994985212f4d (diff)
downloaddjango-9f7809ece37cc8b5f3239908fbdcebe32606ce2d.tar.gz
Refs #32499 -- Added more tests for simplify_regex().
Diffstat (limited to 'tests/admin_docs')
-rw-r--r--tests/admin_docs/test_views.py13
1 files changed, 12 insertions, 1 deletions
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<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+)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/'),
)
for pattern, output in tests: