From 731bdfe68ae8dd332702b1838db44f0efe433e2e Mon Sep 17 00:00:00 2001 From: "Buddy Lindsey, Jr" Date: Mon, 1 Feb 2016 11:24:33 -0600 Subject: [PATCH] Fixed #26155 -- Skipped URL checks if no ROOTURL_CONF setting. --- django/core/checks/urls.py | 10 +++++++--- docs/releases/1.9.3.txt | 3 ++- tests/check_framework/test_urls.py | 7 +++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/django/core/checks/urls.py b/django/core/checks/urls.py index a7fca3358f..176cd16190 100644 --- a/django/core/checks/urls.py +++ b/django/core/checks/urls.py @@ -1,13 +1,17 @@ from __future__ import unicode_literals +from django.conf import settings + from . import Tags, Warning, register @register(Tags.urls) def check_url_config(app_configs, **kwargs): - from django.urls import get_resolver - resolver = get_resolver() - return check_resolver(resolver) + if getattr(settings, 'ROOT_URLCONF', None): + from django.urls import get_resolver + resolver = get_resolver() + return check_resolver(resolver) + return [] def check_resolver(resolver): diff --git a/docs/releases/1.9.3.txt b/docs/releases/1.9.3.txt index 6ded7fb256..8686f32c5c 100644 --- a/docs/releases/1.9.3.txt +++ b/docs/releases/1.9.3.txt @@ -9,4 +9,5 @@ Django 1.9.3 fixes several bugs in 1.9.2. Bugfixes ======== -* ... +* Skipped URL checks (new in 1.9) if the ``ROOT_URLCONF`` setting isn't defined + (:ticket:`26155`). diff --git a/tests/check_framework/test_urls.py b/tests/check_framework/test_urls.py index 19f2d2990e..7fe13c9c40 100644 --- a/tests/check_framework/test_urls.py +++ b/tests/check_framework/test_urls.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.core.checks.urls import check_url_config from django.test import SimpleTestCase from django.test.utils import override_settings @@ -35,3 +36,9 @@ class CheckUrlsTest(SimpleTestCase): self.assertEqual(warning.id, 'urls.W003') expected_msg = "Your URL pattern '^$' [name='name_with:colon'] has a name including a ':'." self.assertIn(expected_msg, warning.msg) + + @override_settings(ROOT_URLCONF=None) + def test_no_root_urlconf_in_settings(self): + delattr(settings, 'ROOT_URLCONF') + result = check_url_config(None) + self.assertEqual(result, [])