Code

Ticket #17914: 17914-test.patch

File 17914-test.patch, 2.5 KB (added by Bradley Ayers <bradley.ayers@…>, 2 years ago)

test to expose bug

  • tests/regressiontests/urlpatterns_reverse/views.py

     
    2626        return HttpResponse('') 
    2727 
    2828view_class_instance = ViewClass() 
     29view_class_instance2 = ViewClass() 
    2930 
    3031class LazyRedirectView(RedirectView): 
    3132    url = reverse_lazy('named-lazy-url-redirected-to') 
  • tests/regressiontests/urlpatterns_reverse/tests.py

     
    278278class NamespaceTests(TestCase): 
    279279    urls = 'regressiontests.urlpatterns_reverse.namespace_urls' 
    280280 
     281    def test_function_reference(self): 
     282        self.assertEqual('/included/view_class/level2/', reverse(views.view_class_instance2)) 
     283 
    281284    def test_ambiguous_object(self): 
    282285        "Names deployed via dynamic URL objects that require namespaces can't be resolved" 
    283286        self.assertRaises(NoReverseMatch, reverse, 'urlobject-view') 
  • tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py

     
    33from django.conf.urls import patterns, url, include 
    44 
    55from .namespace_urls import URLObject 
    6 from .views import view_class_instance 
     6from .views import view_class_instance, view_class_instance2 
    77 
    88 
    99testobj3 = URLObject('testapp', 'test-ns3') 
    1010 
     11level2_patterns = patterns("", 
     12    (r'^level2/$', view_class_instance2) 
     13) 
     14 
    1115urlpatterns = patterns('regressiontests.urlpatterns_reverse.views', 
    1216    url(r'^normal/$', 'empty_view', name='inc-normal-view'), 
    1317    url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='inc-normal-view'), 
     
    1822    url(r'^no_kwargs/(\d+)/(\d+)/$', 'empty_view', name='inc-no-kwargs'), 
    1923 
    2024    url(r'^view_class/(?P<arg1>\d+)/(?P<arg2>\d+)/$', view_class_instance, name='inc-view-class'), 
     25    url(r'^view_class/level2/$', include(level2_patterns)), 
    2126 
    2227    (r'^test3/', include(testobj3.urls)), 
    2328    (r'^ns-included3/', include('regressiontests.urlpatterns_reverse.included_urls', namespace='inc-ns3')),