mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 00:49:49 +03:00
url() -> path()/re_path()
This commit is contained in:
parent
4c90760aef
commit
5c26cc6bdb
|
@ -1,7 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from django.conf.urls import include, url
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls import Resolver404
|
from django.urls import Resolver404
|
||||||
|
|
||||||
|
@ -62,7 +61,7 @@ class FormatSuffixTests(TestCase):
|
||||||
|
|
||||||
def test_trailing_slash(self):
|
def test_trailing_slash(self):
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^test/$', dummy_view),
|
re_path(r'^test/$', dummy_view),
|
||||||
]
|
]
|
||||||
self._test_trailing_slash(urlpatterns)
|
self._test_trailing_slash(urlpatterns)
|
||||||
|
|
||||||
|
@ -83,7 +82,7 @@ class FormatSuffixTests(TestCase):
|
||||||
|
|
||||||
def test_format_suffix(self):
|
def test_format_suffix(self):
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^test$', dummy_view),
|
re_path(r'^test$', dummy_view),
|
||||||
]
|
]
|
||||||
self._test_format_suffix(urlpatterns)
|
self._test_format_suffix(urlpatterns)
|
||||||
|
|
||||||
|
@ -120,7 +119,7 @@ class FormatSuffixTests(TestCase):
|
||||||
|
|
||||||
def test_default_args(self):
|
def test_default_args(self):
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^test$', dummy_view, {'foo': 'bar'}),
|
re_path(r'^test$', dummy_view, {'foo': 'bar'}),
|
||||||
]
|
]
|
||||||
self._test_default_args(urlpatterns)
|
self._test_default_args(urlpatterns)
|
||||||
|
|
||||||
|
@ -141,10 +140,10 @@ class FormatSuffixTests(TestCase):
|
||||||
|
|
||||||
def test_included_urls(self):
|
def test_included_urls(self):
|
||||||
nested_patterns = [
|
nested_patterns = [
|
||||||
url(r'^path$', dummy_view)
|
re_path(r'^path$', dummy_view)
|
||||||
]
|
]
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^test/', include(nested_patterns), {'foo': 'bar'}),
|
re_path(r'^test/', include(nested_patterns), {'foo': 'bar'}),
|
||||||
]
|
]
|
||||||
self._test_included_urls(urlpatterns)
|
self._test_included_urls(urlpatterns)
|
||||||
|
|
||||||
|
@ -164,7 +163,7 @@ class FormatSuffixTests(TestCase):
|
||||||
path('path', dummy_view)
|
path('path', dummy_view)
|
||||||
]
|
]
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url('^test/', include(nested_patterns), {'foo': 'bar'}),
|
re_path('^test/', include(nested_patterns), {'foo': 'bar'}),
|
||||||
]
|
]
|
||||||
self._test_included_urls(urlpatterns)
|
self._test_included_urls(urlpatterns)
|
||||||
|
|
||||||
|
@ -172,10 +171,10 @@ class FormatSuffixTests(TestCase):
|
||||||
def test_included_urls_django2_mixed_args(self):
|
def test_included_urls_django2_mixed_args(self):
|
||||||
nested_patterns = [
|
nested_patterns = [
|
||||||
path('path/<int:child>', dummy_view),
|
path('path/<int:child>', dummy_view),
|
||||||
url('^url/(?P<child>[0-9]+)$', dummy_view)
|
re_path('^url/(?P<child>[0-9]+)$', dummy_view)
|
||||||
]
|
]
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url('^purl/(?P<parent>[0-9]+)/', include(nested_patterns), {'foo': 'bar'}),
|
re_path('^purl/(?P<parent>[0-9]+)/', include(nested_patterns), {'foo': 'bar'}),
|
||||||
path('ppath/<int:parent>/', include(nested_patterns), {'foo': 'bar'}),
|
path('ppath/<int:parent>/', include(nested_patterns), {'foo': 'bar'}),
|
||||||
]
|
]
|
||||||
test_paths = [
|
test_paths = [
|
||||||
|
@ -212,7 +211,7 @@ class FormatSuffixTests(TestCase):
|
||||||
|
|
||||||
def test_allowed_formats(self):
|
def test_allowed_formats(self):
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url('^test$', dummy_view),
|
path('test', dummy_view),
|
||||||
]
|
]
|
||||||
self._test_allowed_formats(urlpatterns)
|
self._test_allowed_formats(urlpatterns)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user