Ticket #17173: specialchar-unittest-1.3.1.patch
File specialchar-unittest-1.3.1.patch, 8.6 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/urlpatterns_reverse/namespace_urls.py
14 14 return patterns('', 15 15 url(r'^inner/$', 'empty_view', name='urlobject-view'), 16 16 url(r'^inner/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='urlobject-view'), 17 url(r'^inner/\+\\\$\*/$', 'empty_view', name='urlobject-special-view'), 17 18 ), self.app_name, self.namespace 18 19 urls = property(urls) 19 20 … … 28 29 url(r'^normal/$', 'empty_view', name='normal-view'), 29 30 url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='normal-view'), 30 31 32 url(r'^\+\\\$\*/$', 'empty_view', name='special-view'), 33 31 34 url(r'^mixed_args/(\d+)/(?P<arg2>\d+)/$', 'empty_view', name='mixed-args'), 32 35 url(r'^no_kwargs/(\d+)/(\d+)/$', 'empty_view', name='no-kwargs'), 33 36 … … 50 53 51 54 (r'^ns-outer/(?P<outer>\d+)/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-outer')), 52 55 56 (r'^\+\\\$\*/', include('regressiontests.urlpatterns_reverse.namespace_urls', namespace='special')), 53 57 ) -
tests/regressiontests/urlpatterns_reverse/tests.py
294 294 self.assertEqual('/normal/', reverse('normal-view')) 295 295 self.assertEqual('/normal/37/42/', reverse('normal-view', args=[37,42])) 296 296 self.assertEqual('/normal/42/37/', reverse('normal-view', kwargs={'arg1':42, 'arg2':37})) 297 self.assertEqual('/+%5C$*/', reverse('special-view')) 297 298 298 299 def test_simple_included_name(self): 299 300 "Normal lookups work on names included from other patterns" 300 301 self.assertEqual('/included/normal/', reverse('inc-normal-view')) 301 302 self.assertEqual('/included/normal/37/42/', reverse('inc-normal-view', args=[37,42])) 302 303 self.assertEqual('/included/normal/42/37/', reverse('inc-normal-view', kwargs={'arg1':42, 'arg2':37})) 304 self.assertEqual('/included/+%5C$*/', reverse('inc-special-view')) 303 305 304 306 def test_namespace_object(self): 305 307 "Dynamic URL objects can be found using a namespace" 306 308 self.assertEqual('/test1/inner/', reverse('test-ns1:urlobject-view')) 307 309 self.assertEqual('/test1/inner/37/42/', reverse('test-ns1:urlobject-view', args=[37,42])) 308 310 self.assertEqual('/test1/inner/42/37/', reverse('test-ns1:urlobject-view', kwargs={'arg1':42, 'arg2':37})) 311 self.assertEqual('/test1/inner/+%5C$*/', reverse('test-ns1:urlobject-special-view')) 309 312 310 313 def test_embedded_namespace_object(self): 311 314 "Namespaces can be installed anywhere in the URL pattern tree" 312 315 self.assertEqual('/included/test3/inner/', reverse('test-ns3:urlobject-view')) 313 316 self.assertEqual('/included/test3/inner/37/42/', reverse('test-ns3:urlobject-view', args=[37,42])) 314 317 self.assertEqual('/included/test3/inner/42/37/', reverse('test-ns3:urlobject-view', kwargs={'arg1':42, 'arg2':37})) 318 self.assertEqual('/included/test3/inner/+%5C$*/', reverse('test-ns3:urlobject-special-view')) 315 319 316 320 def test_namespace_pattern(self): 317 321 "Namespaces can be applied to include()'d urlpatterns" 318 322 self.assertEqual('/ns-included1/normal/', reverse('inc-ns1:inc-normal-view')) 319 323 self.assertEqual('/ns-included1/normal/37/42/', reverse('inc-ns1:inc-normal-view', args=[37,42])) 320 324 self.assertEqual('/ns-included1/normal/42/37/', reverse('inc-ns1:inc-normal-view', kwargs={'arg1':42, 'arg2':37})) 325 self.assertEqual('/ns-included1/+%5C$*/', reverse('inc-ns1:inc-special-view')) 321 326 322 327 def test_namespace_pattern_with_variable_prefix(self): 323 328 "When using a include with namespaces when there is a regex variable in front of it" … … 331 336 self.assertEqual('/ns-included1/test3/inner/', reverse('inc-ns1:test-ns3:urlobject-view')) 332 337 self.assertEqual('/ns-included1/test3/inner/37/42/', reverse('inc-ns1:test-ns3:urlobject-view', args=[37,42])) 333 338 self.assertEqual('/ns-included1/test3/inner/42/37/', reverse('inc-ns1:test-ns3:urlobject-view', kwargs={'arg1':42, 'arg2':37})) 339 self.assertEqual('/ns-included1/test3/inner/+%5C$*/', reverse('inc-ns1:test-ns3:urlobject-special-view')) 334 340 335 341 def test_nested_namespace_pattern(self): 336 342 "Namespaces can be nested" 337 343 self.assertEqual('/ns-included1/ns-included4/ns-included1/test3/inner/', reverse('inc-ns1:inc-ns4:inc-ns1:test-ns3:urlobject-view')) 338 344 self.assertEqual('/ns-included1/ns-included4/ns-included1/test3/inner/37/42/', reverse('inc-ns1:inc-ns4:inc-ns1:test-ns3:urlobject-view', args=[37,42])) 339 345 self.assertEqual('/ns-included1/ns-included4/ns-included1/test3/inner/42/37/', reverse('inc-ns1:inc-ns4:inc-ns1:test-ns3:urlobject-view', kwargs={'arg1':42, 'arg2':37})) 346 self.assertEqual('/ns-included1/ns-included4/ns-included1/test3/inner/+%5C$*/', reverse('inc-ns1:inc-ns4:inc-ns1:test-ns3:urlobject-special-view')) 340 347 341 348 def test_app_lookup_object(self): 342 349 "A default application namespace can be used for lookup" 343 350 self.assertEqual('/default/inner/', reverse('testapp:urlobject-view')) 344 351 self.assertEqual('/default/inner/37/42/', reverse('testapp:urlobject-view', args=[37,42])) 345 352 self.assertEqual('/default/inner/42/37/', reverse('testapp:urlobject-view', kwargs={'arg1':42, 'arg2':37})) 353 self.assertEqual('/default/inner/+%5C$*/', reverse('testapp:urlobject-special-view')) 346 354 347 355 def test_app_lookup_object_with_default(self): 348 356 "A default application namespace is sensitive to the 'current' app can be used for lookup" 349 357 self.assertEqual('/included/test3/inner/', reverse('testapp:urlobject-view', current_app='test-ns3')) 350 358 self.assertEqual('/included/test3/inner/37/42/', reverse('testapp:urlobject-view', args=[37,42], current_app='test-ns3')) 351 359 self.assertEqual('/included/test3/inner/42/37/', reverse('testapp:urlobject-view', kwargs={'arg1':42, 'arg2':37}, current_app='test-ns3')) 360 self.assertEqual('/included/test3/inner/+%5C$*/', reverse('testapp:urlobject-special-view', current_app='test-ns3')) 352 361 353 362 def test_app_lookup_object_without_default(self): 354 363 "An application namespace without a default is sensitive to the 'current' app can be used for lookup" 355 364 self.assertEqual('/other2/inner/', reverse('nodefault:urlobject-view')) 356 365 self.assertEqual('/other2/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42])) 357 366 self.assertEqual('/other2/inner/42/37/', reverse('nodefault:urlobject-view', kwargs={'arg1':42, 'arg2':37})) 367 self.assertEqual('/other2/inner/+%5C$*/', reverse('nodefault:urlobject-special-view')) 358 368 359 369 self.assertEqual('/other1/inner/', reverse('nodefault:urlobject-view', current_app='other-ns1')) 360 370 self.assertEqual('/other1/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42], current_app='other-ns1')) 361 371 self.assertEqual('/other1/inner/42/37/', reverse('nodefault:urlobject-view', kwargs={'arg1':42, 'arg2':37}, current_app='other-ns1')) 372 self.assertEqual('/other1/inner/+%5C$*/', reverse('nodefault:urlobject-special-view', current_app='other-ns1')) 362 373 374 def test_special_chars_namespace(self): 375 self.assertEqual('/+%5C$*/included/normal/', reverse('special:inc-normal-view')) 376 self.assertEqual('/+%5C$*/included/normal/37/42/', reverse('special:inc-normal-view', args=[37,42])) 377 self.assertEqual('/+%5C$*/included/normal/42/37/', reverse('special:inc-normal-view', kwargs={'arg1':42, 'arg2':37})) 378 self.assertEqual('/+%5C$*/included/+%5C$*/', reverse('special:inc-special-view')) 379 363 380 class RequestURLconfTests(TestCase): 364 381 def setUp(self): 365 382 self.root_urlconf = settings.ROOT_URLCONF -
tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py
12 12 url(r'^normal/$', 'empty_view', name='inc-normal-view'), 13 13 url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='inc-normal-view'), 14 14 15 url(r'^\+\\\$\*/$', 'empty_view', name='inc-special-view'), 16 15 17 url(r'^mixed_args/(\d+)/(?P<arg2>\d+)/$', 'empty_view', name='inc-mixed-args'), 16 18 url(r'^no_kwargs/(\d+)/(\d+)/$', 'empty_view', name='inc-no-kwargs'), 17 19