1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #35252 -- Optimized _route_to_regex().

co-authored-by: Nick Pope <nick@nickpope.me.uk>
This commit is contained in:
Adam Johnson
2024-02-26 10:41:15 +00:00
committed by Mariusz Felisiak
parent 241adf678f
commit eff21d8e7a
4 changed files with 34 additions and 33 deletions

View File

@@ -246,14 +246,12 @@ class SimplifiedURLTests(SimpleTestCase):
path("foo", EmptyCBV())
def test_whitespace_in_route(self):
msg = (
"URL route 'space/<int:num>/extra/<str:%stest>' cannot contain "
"whitespace in angle brackets <…>"
)
msg = "URL route %r cannot contain whitespace in angle brackets <…>"
for whitespace in string.whitespace:
with self.subTest(repr(whitespace)):
with self.assertRaisesMessage(ImproperlyConfigured, msg % whitespace):
path("space/<int:num>/extra/<str:%stest>" % whitespace, empty_view)
route = "space/<int:num>/extra/<str:%stest>" % whitespace
with self.assertRaisesMessage(ImproperlyConfigured, msg % route):
path(route, empty_view)
# Whitespaces are valid in paths.
p = path("space%s/<int:num>/" % string.whitespace, empty_view)
match = p.resolve("space%s/1/" % string.whitespace)