99from django .test import TestCase , override_settings
1010
1111from rest_framework import permissions , serializers , viewsets
12+ from rest_framework .compat import get_regex_pattern
1213from rest_framework .decorators import detail_route , list_route
1314from rest_framework .response import Response
1415from rest_framework .routers import DefaultRouter , SimpleRouter
@@ -97,7 +98,7 @@ def regex_url_path_detail(self, request, *args, **kwargs):
9798
9899urlpatterns = [
99100 url (r'^non-namespaced/' , include (namespaced_router .urls )),
100- url (r'^namespaced/' , include (namespaced_router .urls , namespace = 'example' , app_name = 'example' )),
101+ url (r'^namespaced/' , include (( namespaced_router .urls , 'example' ), namespace = 'example' )),
101102 url (r'^example/' , include (notes_router .urls )),
102103 url (r'^example2/' , include (kwarged_notes_router .urls )),
103104
@@ -176,7 +177,7 @@ def setUp(self):
176177
177178 def test_custom_lookup_field_route (self ):
178179 detail_route = notes_router .urls [- 1 ]
179- detail_url_pattern = detail_route . regex . pattern
180+ detail_url_pattern = get_regex_pattern ( detail_route )
180181 assert '<uuid>' in detail_url_pattern
181182
182183 def test_retrieve_lookup_field_list_view (self ):
@@ -213,7 +214,7 @@ class NoteViewSet(viewsets.ModelViewSet):
213214 def test_urls_limited_by_lookup_value_regex (self ):
214215 expected = ['^notes/$' , '^notes/(?P<uuid>[0-9a-f]{32})/$' ]
215216 for idx in range (len (expected )):
216- assert expected [idx ] == self .urls [idx ]. regex . pattern
217+ assert expected [idx ] == get_regex_pattern ( self .urls [idx ])
217218
218219
219220@override_settings (ROOT_URLCONF = 'tests.test_routers' )
@@ -228,7 +229,7 @@ def setUp(self):
228229
229230 def test_custom_lookup_url_kwarg_route (self ):
230231 detail_route = kwarged_notes_router .urls [- 1 ]
231- detail_url_pattern = detail_route . regex . pattern
232+ detail_url_pattern = get_regex_pattern ( detail_route )
232233 assert '^notes/(?P<text>' in detail_url_pattern
233234
234235 def test_retrieve_lookup_url_kwarg_detail_view (self ):
@@ -252,7 +253,7 @@ class NoteViewSet(viewsets.ModelViewSet):
252253 def test_urls_have_trailing_slash_by_default (self ):
253254 expected = ['^notes/$' , '^notes/(?P<pk>[^/.]+)/$' ]
254255 for idx in range (len (expected )):
255- assert expected [idx ] == self .urls [idx ]. regex . pattern
256+ assert expected [idx ] == get_regex_pattern ( self .urls [idx ])
256257
257258
258259class TestTrailingSlashRemoved (TestCase ):
@@ -267,7 +268,7 @@ class NoteViewSet(viewsets.ModelViewSet):
267268 def test_urls_can_have_trailing_slash_removed (self ):
268269 expected = ['^notes$' , '^notes/(?P<pk>[^/.]+)$' ]
269270 for idx in range (len (expected )):
270- assert expected [idx ] == self .urls [idx ]. regex . pattern
271+ assert expected [idx ] == get_regex_pattern ( self .urls [idx ])
271272
272273
273274class TestNameableRoot (TestCase ):
0 commit comments