From 4bb33bb07450ea9b623877417c28e6489246f51c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 13 Apr 2020 09:07:28 +0100 Subject: Fixed #31459 -- Fixed handling invalid indentifiers in URL path conversion. This patch adjusted existing tests that used invalid identifiers. --- tests/urlpatterns/tests.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/urlpatterns') diff --git a/tests/urlpatterns/tests.py b/tests/urlpatterns/tests.py index 0de0f6f05d..b6353873ae 100644 --- a/tests/urlpatterns/tests.py +++ b/tests/urlpatterns/tests.py @@ -249,7 +249,7 @@ class SameNameTests(SimpleTestCase): class ParameterRestrictionTests(SimpleTestCase): - def test_non_identifier_parameter_name_causes_exception(self): + def test_integer_parameter_name_causes_exception(self): msg = ( "URL route 'hello//' uses parameter name '1' which isn't " "a valid Python identifier." @@ -257,6 +257,14 @@ class ParameterRestrictionTests(SimpleTestCase): with self.assertRaisesMessage(ImproperlyConfigured, msg): path(r'hello//', lambda r: None) + def test_non_identifier_parameter_name_causes_exception(self): + msg = ( + "URL route 'b//' uses parameter name 'book.id' which " + "isn't a valid Python identifier." + ) + with self.assertRaisesMessage(ImproperlyConfigured, msg): + path(r'b//', lambda r: None) + def test_allows_non_ascii_but_valid_identifiers(self): # \u0394 is "GREEK CAPITAL LETTER DELTA", a valid identifier. p = path('hello//', lambda r: None) -- cgit v1.3