88from django .urls import resolve , reverse
99
1010from rest_framework import permissions , serializers , viewsets
11- from rest_framework .compat import get_regex_pattern
1211from rest_framework .decorators import action
1312from rest_framework .response import Response
1413from rest_framework .routers import DefaultRouter , SimpleRouter
@@ -192,8 +191,7 @@ def setUp(self):
192191
193192 def test_custom_lookup_field_route (self ):
194193 detail_route = notes_router .urls [- 1 ]
195- detail_url_pattern = get_regex_pattern (detail_route )
196- assert '<uuid>' in detail_url_pattern
194+ assert '<uuid>' in detail_route .pattern .regex .pattern
197195
198196 def test_retrieve_lookup_field_list_view (self ):
199197 response = self .client .get ('/example/notes/' )
@@ -229,7 +227,7 @@ class NoteViewSet(viewsets.ModelViewSet):
229227 def test_urls_limited_by_lookup_value_regex (self ):
230228 expected = ['^notes/$' , '^notes/(?P<uuid>[0-9a-f]{32})/$' ]
231229 for idx in range (len (expected )):
232- assert expected [idx ] == get_regex_pattern ( self .urls [idx ])
230+ assert expected [idx ] == self .urls [idx ]. pattern . regex . pattern
233231
234232
235233@override_settings (ROOT_URLCONF = 'tests.test_routers' )
@@ -249,8 +247,7 @@ def setUp(self):
249247
250248 def test_custom_lookup_url_kwarg_route (self ):
251249 detail_route = kwarged_notes_router .urls [- 1 ]
252- detail_url_pattern = get_regex_pattern (detail_route )
253- assert '^notes/(?P<text>' in detail_url_pattern
250+ assert '^notes/(?P<text>' in detail_route .pattern .regex .pattern
254251
255252 def test_retrieve_lookup_url_kwarg_detail_view (self ):
256253 response = self .client .get ('/example2/notes/fo/' )
@@ -273,7 +270,7 @@ class NoteViewSet(viewsets.ModelViewSet):
273270 def test_urls_have_trailing_slash_by_default (self ):
274271 expected = ['^notes/$' , '^notes/(?P<pk>[^/.]+)/$' ]
275272 for idx in range (len (expected )):
276- assert expected [idx ] == get_regex_pattern ( self .urls [idx ])
273+ assert expected [idx ] == self .urls [idx ]. pattern . regex . pattern
277274
278275
279276class TestTrailingSlashRemoved (TestCase ):
@@ -288,7 +285,7 @@ class NoteViewSet(viewsets.ModelViewSet):
288285 def test_urls_can_have_trailing_slash_removed (self ):
289286 expected = ['^notes$' , '^notes/(?P<pk>[^/.]+)$' ]
290287 for idx in range (len (expected )):
291- assert expected [idx ] == get_regex_pattern ( self .urls [idx ])
288+ assert expected [idx ] == self .urls [idx ]. pattern . regex . pattern
292289
293290
294291class TestNameableRoot (TestCase ):
0 commit comments