Ticket #17173: specialchar-unittest-1.3.1.patch

File specialchar-unittest-1.3.1.patch, 8.6 KB (added by kaiser.yann@…, 4 years ago)

Same for 1.3.1

  • tests/regressiontests/urlpatterns_reverse/namespace_urls.py

     
    1414        return patterns('',
    1515            url(r'^inner/$', 'empty_view', name='urlobject-view'),
    1616            url(r'^inner/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='urlobject-view'),
     17            url(r'^inner/\+\\\$\*/$', 'empty_view', name='urlobject-special-view'),
    1718        ), self.app_name, self.namespace
    1819    urls = property(urls)
    1920
     
    2829    url(r'^normal/$', 'empty_view', name='normal-view'),
    2930    url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='normal-view'),
    3031
     32    url(r'^\+\\\$\*/$', 'empty_view', name='special-view'),
     33
    3134    url(r'^mixed_args/(\d+)/(?P<arg2>\d+)/$', 'empty_view', name='mixed-args'),
    3235    url(r'^no_kwargs/(\d+)/(\d+)/$', 'empty_view', name='no-kwargs'),
    3336
     
    5053
    5154    (r'^ns-outer/(?P<outer>\d+)/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-outer')),
    5255
     56    (r'^\+\\\$\*/', include('regressiontests.urlpatterns_reverse.namespace_urls', namespace='special')),
    5357)
  • tests/regressiontests/urlpatterns_reverse/tests.py

     
    294294        self.assertEqual('/normal/', reverse('normal-view'))
    295295        self.assertEqual('/normal/37/42/', reverse('normal-view', args=[37,42]))
    296296        self.assertEqual('/normal/42/37/', reverse('normal-view', kwargs={'arg1':42, 'arg2':37}))
     297        self.assertEqual('/+%5C$*/', reverse('special-view'))
    297298
    298299    def test_simple_included_name(self):
    299300        "Normal lookups work on names included from other patterns"
    300301        self.assertEqual('/included/normal/', reverse('inc-normal-view'))
    301302        self.assertEqual('/included/normal/37/42/', reverse('inc-normal-view', args=[37,42]))
    302303        self.assertEqual('/included/normal/42/37/', reverse('inc-normal-view', kwargs={'arg1':42, 'arg2':37}))
     304        self.assertEqual('/included/+%5C$*/', reverse('inc-special-view'))
    303305
    304306    def test_namespace_object(self):
    305307        "Dynamic URL objects can be found using a namespace"
    306308        self.assertEqual('/test1/inner/', reverse('test-ns1:urlobject-view'))
    307309        self.assertEqual('/test1/inner/37/42/', reverse('test-ns1:urlobject-view', args=[37,42]))
    308310        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'))
    309312
    310313    def test_embedded_namespace_object(self):
    311314        "Namespaces can be installed anywhere in the URL pattern tree"
    312315        self.assertEqual('/included/test3/inner/', reverse('test-ns3:urlobject-view'))
    313316        self.assertEqual('/included/test3/inner/37/42/', reverse('test-ns3:urlobject-view', args=[37,42]))
    314317        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'))
    315319
    316320    def test_namespace_pattern(self):
    317321        "Namespaces can be applied to include()'d urlpatterns"
    318322        self.assertEqual('/ns-included1/normal/', reverse('inc-ns1:inc-normal-view'))
    319323        self.assertEqual('/ns-included1/normal/37/42/', reverse('inc-ns1:inc-normal-view', args=[37,42]))
    320324        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'))
    321326
    322327    def test_namespace_pattern_with_variable_prefix(self):
    323328        "When using a include with namespaces when there is a regex variable in front of it"
     
    331336        self.assertEqual('/ns-included1/test3/inner/', reverse('inc-ns1:test-ns3:urlobject-view'))
    332337        self.assertEqual('/ns-included1/test3/inner/37/42/', reverse('inc-ns1:test-ns3:urlobject-view', args=[37,42]))
    333338        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'))
    334340
    335341    def test_nested_namespace_pattern(self):
    336342        "Namespaces can be nested"
    337343        self.assertEqual('/ns-included1/ns-included4/ns-included1/test3/inner/', reverse('inc-ns1:inc-ns4:inc-ns1:test-ns3:urlobject-view'))
    338344        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]))
    339345        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'))
    340347
    341348    def test_app_lookup_object(self):
    342349        "A default application namespace can be used for lookup"
    343350        self.assertEqual('/default/inner/', reverse('testapp:urlobject-view'))
    344351        self.assertEqual('/default/inner/37/42/', reverse('testapp:urlobject-view', args=[37,42]))
    345352        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'))
    346354
    347355    def test_app_lookup_object_with_default(self):
    348356        "A default application namespace is sensitive to the 'current' app can be used for lookup"
    349357        self.assertEqual('/included/test3/inner/', reverse('testapp:urlobject-view', current_app='test-ns3'))
    350358        self.assertEqual('/included/test3/inner/37/42/', reverse('testapp:urlobject-view', args=[37,42], current_app='test-ns3'))
    351359        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'))
    352361
    353362    def test_app_lookup_object_without_default(self):
    354363        "An application namespace without a default is sensitive to the 'current' app can be used for lookup"
    355364        self.assertEqual('/other2/inner/', reverse('nodefault:urlobject-view'))
    356365        self.assertEqual('/other2/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42]))
    357366        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'))
    358368
    359369        self.assertEqual('/other1/inner/', reverse('nodefault:urlobject-view', current_app='other-ns1'))
    360370        self.assertEqual('/other1/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42], current_app='other-ns1'))
    361371        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'))
    362373
     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
    363380class RequestURLconfTests(TestCase):
    364381    def setUp(self):
    365382        self.root_urlconf = settings.ROOT_URLCONF
  • tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py

     
    1212    url(r'^normal/$', 'empty_view', name='inc-normal-view'),
    1313    url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='inc-normal-view'),
    1414
     15    url(r'^\+\\\$\*/$', 'empty_view', name='inc-special-view'),
     16
    1517    url(r'^mixed_args/(\d+)/(?P<arg2>\d+)/$', 'empty_view', name='inc-mixed-args'),
    1618    url(r'^no_kwargs/(\d+)/(\d+)/$', 'empty_view', name='inc-no-kwargs'),
    1719
Back to Top