Added an explicit test that URL checks are recursive.

This commit is contained in:
Alasdair Nicol 2016-04-27 22:38:00 +01:00 committed by Tim Graham
parent 86573861a9
commit ffb1c532ec
5 changed files with 20 additions and 11 deletions

View File

@ -10,6 +10,14 @@ class CheckUrlsTest(SimpleTestCase):
result = check_url_config(None)
self.assertEqual(result, [])
@override_settings(ROOT_URLCONF='check_framework.urls.warning_in_include')
def test_check_resolver_recursive(self):
# The resolver is checked recursively (examining url()s in include()).
result = check_url_config(None)
self.assertEqual(len(result), 1)
warning = result[0]
self.assertEqual(warning.id, 'urls.W001')
@override_settings(ROOT_URLCONF='check_framework.urls.include_with_dollar')
def test_include_with_dollar(self):
result = check_url_config(None)

View File

@ -1,7 +1,5 @@
from django.conf.urls import include, url
from django.conf.urls import url
urlpatterns = [
url('^', include([
url(r'/starting-with-slash/$', lambda x: x),
])),
url(r'/starting-with-slash/$', lambda x: x),
]

View File

@ -1,7 +1,5 @@
from django.conf.urls import include, url
urlpatterns = [
url(r'^', include([
url(r'^include-with-dollar$', include([])),
])),
url(r'^include-with-dollar$', include([])),
]

View File

@ -1,7 +1,5 @@
from django.conf.urls import include, url
from django.conf.urls import url
urlpatterns = [
url('^', include([
url(r'^$', lambda x: x, name='name_with:colon'),
])),
url(r'^$', lambda x: x, name='name_with:colon'),
]

View File

@ -0,0 +1,7 @@
from django.conf.urls import include, url
urlpatterns = [
url(r'^', include([
url(r'^include-with-dollar$', include([])),
])),
]