Ticket #30731: demo.py

File demo.py, 813 bytes (added by Alan Crosswell, 5 years ago)
Line 
1from django.contrib.admindocs.utils import replace_named_groups
2
3path_regex = r'entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)'
4expected_path = 'entries/<pk>/relationships/<related_field>'
5path_regex_trailing = path_regex + '/'
6expected_path_trailing = expected_path + '/'
7
8path_trailing = replace_named_groups(path_regex_trailing)
9path = replace_named_groups(path_regex)
10
11print(' path:', path_regex)
12print(' expected:', expected_path)
13print(' got:', path)
14print()
15print('path_trailing:', path_regex_trailing)
16print(' expected:', expected_path_trailing)
17print(' got:', path_trailing)
18
19assert path_trailing == expected_path_trailing, "path with trailing slash didn't match expected"
20
21assert path == expected_path, "path without trailing slash didn't match expected"
22
Back to Top