File tree Expand file tree Collapse file tree 5 files changed +13
-5
lines changed Expand file tree Collapse file tree 5 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ def __str__(self):
197197
198198
199199_PATH_PARAMETER_COMPONENT_RE = _lazy_re_compile (
200- r'<(?:(?P<converter>[^>:]+):)?(?P<parameter>\w +)>'
200+ r'<(?:(?P<converter>[^>:]+):)?(?P<parameter>[^>] +)>'
201201)
202202
203203
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ def test_contains_re_named_group(self):
143143 self .assertEqual (len (result ), 1 )
144144 warning = result [0 ]
145145 self .assertEqual (warning .id , '2_0.W001' )
146- expected_msg = "Your URL pattern '(?P<named-group >\\ d+)' has a route"
146+ expected_msg = "Your URL pattern '(?P<named_group >\\ d+)' has a route"
147147 self .assertIn (expected_msg , warning .msg )
148148
149149 @override_settings (ROOT_URLCONF = 'check_framework.urls.path_compatibility.beginning_with_caret' )
Original file line number Diff line number Diff line change 11from django .urls import path
22
33urlpatterns = [
4- path (r'(?P<named-group >\d+)' , lambda x : x ),
4+ path (r'(?P<named_group >\d+)' , lambda x : x ),
55]
Original file line number Diff line number Diff line change 2020 gis_sitemap_views .kml ,
2121 name = 'django.contrib.gis.sitemaps.views.kml' ),
2222 path (
23- 'sitemaps/kml/<label>/<< model>/<field_name>.kmz' ,
23+ 'sitemaps/kml/<label>/<model>/<field_name>.kmz' ,
2424 gis_sitemap_views .kmz ,
2525 name = 'django.contrib.gis.sitemaps.views.kmz' ),
2626]
Original file line number Diff line number Diff line change @@ -249,14 +249,22 @@ def requires_tiny_int(value):
249249
250250
251251class ParameterRestrictionTests (SimpleTestCase ):
252- def test_non_identifier_parameter_name_causes_exception (self ):
252+ def test_integer_parameter_name_causes_exception (self ):
253253 msg = (
254254 "URL route 'hello/<int:1>/' uses parameter name '1' which isn't "
255255 "a valid Python identifier."
256256 )
257257 with self .assertRaisesMessage (ImproperlyConfigured , msg ):
258258 path (r'hello/<int:1>/' , lambda r : None )
259259
260+ def test_non_identifier_parameter_name_causes_exception (self ):
261+ msg = (
262+ "URL route 'b/<int:book.id>/' uses parameter name 'book.id' which "
263+ "isn't a valid Python identifier."
264+ )
265+ with self .assertRaisesMessage (ImproperlyConfigured , msg ):
266+ path (r'b/<int:book.id>/' , lambda r : None )
267+
260268 def test_allows_non_ascii_but_valid_identifiers (self ):
261269 # \u0394 is "GREEK CAPITAL LETTER DELTA", a valid identifier.
262270 p = path ('hello/<str:\u0394 >/' , lambda r : None )
You can’t perform that action at this time.
0 commit comments