8
8
from django .urls import resolve , reverse
9
9
10
10
from rest_framework import permissions , serializers , viewsets
11
- from rest_framework .compat import get_regex_pattern
12
11
from rest_framework .decorators import action
13
12
from rest_framework .response import Response
14
13
from rest_framework .routers import DefaultRouter , SimpleRouter
@@ -192,8 +191,7 @@ def setUp(self):
192
191
193
192
def test_custom_lookup_field_route (self ):
194
193
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
197
195
198
196
def test_retrieve_lookup_field_list_view (self ):
199
197
response = self .client .get ('/example/notes/' )
@@ -229,7 +227,7 @@ class NoteViewSet(viewsets.ModelViewSet):
229
227
def test_urls_limited_by_lookup_value_regex (self ):
230
228
expected = ['^notes/$' , '^notes/(?P<uuid>[0-9a-f]{32})/$' ]
231
229
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
233
231
234
232
235
233
@override_settings (ROOT_URLCONF = 'tests.test_routers' )
@@ -249,8 +247,7 @@ def setUp(self):
249
247
250
248
def test_custom_lookup_url_kwarg_route (self ):
251
249
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
254
251
255
252
def test_retrieve_lookup_url_kwarg_detail_view (self ):
256
253
response = self .client .get ('/example2/notes/fo/' )
@@ -273,7 +270,7 @@ class NoteViewSet(viewsets.ModelViewSet):
273
270
def test_urls_have_trailing_slash_by_default (self ):
274
271
expected = ['^notes/$' , '^notes/(?P<pk>[^/.]+)/$' ]
275
272
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
277
274
278
275
279
276
class TestTrailingSlashRemoved (TestCase ):
@@ -288,7 +285,7 @@ class NoteViewSet(viewsets.ModelViewSet):
288
285
def test_urls_can_have_trailing_slash_removed (self ):
289
286
expected = ['^notes$' , '^notes/(?P<pk>[^/.]+)$' ]
290
287
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
292
289
293
290
294
291
class TestNameableRoot (TestCase ):
0 commit comments