From c970018f41985567b7c4bb858e158cb33a180f8a Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 9 Feb 2015 19:16:07 -0500 Subject: [PATCH] Removed Django 1.7 MIDDLEWARE_CLASSES upgrade check. --- django/core/checks/__init__.py | 1 - django/core/checks/compatibility/__init__.py | 0 .../core/checks/compatibility/django_1_7_0.py | 36 ------------------ docs/ref/checks.txt | 2 +- tests/check_framework/tests.py | 37 ------------------- tests/runtests.py | 2 - 6 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 django/core/checks/compatibility/__init__.py delete mode 100644 django/core/checks/compatibility/django_1_7_0.py diff --git a/django/core/checks/__init__.py b/django/core/checks/__init__.py index e446bdc099..efeddd1bdf 100644 --- a/django/core/checks/__init__.py +++ b/django/core/checks/__init__.py @@ -7,7 +7,6 @@ from .messages import (CheckMessage, from .registry import register, run_checks, tag_exists, Tags # Import these to force registration of checks -import django.core.checks.compatibility.django_1_7_0 # NOQA import django.core.checks.model_checks # NOQA import django.core.checks.security.base # NOQA import django.core.checks.security.csrf # NOQA diff --git a/django/core/checks/compatibility/__init__.py b/django/core/checks/compatibility/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/django/core/checks/compatibility/django_1_7_0.py b/django/core/checks/compatibility/django_1_7_0.py deleted file mode 100644 index 878541d3e5..0000000000 --- a/django/core/checks/compatibility/django_1_7_0.py +++ /dev/null @@ -1,36 +0,0 @@ -from __future__ import unicode_literals - -from .. import Tags, Warning, register - - -@register(Tags.compatibility) -def check_1_7_compatibility(**kwargs): - errors = [] - errors.extend(_check_middleware_classes(**kwargs)) - return errors - - -def _check_middleware_classes(app_configs=None, **kwargs): - """ - Checks if the user has *not* overridden the ``MIDDLEWARE_CLASSES`` setting & - warns them about the global default changes. - """ - from django.conf import settings - - # MIDDLEWARE_CLASSES is overridden by default by startproject. If users - # have removed this override then we'll warn them about the default changes. - if not settings.is_overridden('MIDDLEWARE_CLASSES'): - return [ - Warning( - "MIDDLEWARE_CLASSES is not set.", - hint=("Django 1.7 changed the global defaults for the MIDDLEWARE_CLASSES. " - "django.contrib.sessions.middleware.SessionMiddleware, " - "django.contrib.auth.middleware.AuthenticationMiddleware, and " - "django.contrib.messages.middleware.MessageMiddleware were removed from the defaults. " - "If your project needs these middleware then you should configure this setting."), - obj=None, - id='1_7.W001', - ) - ] - else: - return [] diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt index f5b95da14c..9ba3c492f7 100644 --- a/docs/ref/checks.txt +++ b/docs/ref/checks.txt @@ -182,7 +182,7 @@ that might occur as a result of a version upgrade. ``django.contrib.auth.middleware.AuthenticationMiddleware``, and ``django.contrib.messages.middleware.MessageMiddleware`` were removed from the defaults. If your project needs these middleware then you should - configure this setting. + configure this setting. *This check was removed in Django 1.9*. Admin ----- diff --git a/tests/check_framework/tests.py b/tests/check_framework/tests.py index 167d0087ee..3c79e9ba51 100644 --- a/tests/check_framework/tests.py +++ b/tests/check_framework/tests.py @@ -4,11 +4,8 @@ from __future__ import unicode_literals import sys from django.apps import apps -from django.conf import settings from django.core import checks from django.core.checks import Error, Warning -from django.core.checks.compatibility.django_1_7_0 import \ - check_1_7_compatibility from django.core.checks.registry import CheckRegistry from django.core.management import call_command from django.core.management.base import CommandError @@ -112,40 +109,6 @@ class MessageTests(TestCase): self.assertEqual(force_text(e), expected) -class Django_1_7_0_CompatibilityChecks(TestCase): - - @override_settings(MIDDLEWARE_CLASSES=['django.contrib.sessions.middleware.SessionMiddleware']) - def test_middleware_classes_overridden(self): - errors = check_1_7_compatibility() - self.assertEqual(errors, []) - - def test_middleware_classes_not_set_explicitly(self): - # If MIDDLEWARE_CLASSES was set explicitly, temporarily pretend it wasn't - middleware_classes_overridden = False - if 'MIDDLEWARE_CLASSES' in settings._wrapped._explicit_settings: - middleware_classes_overridden = True - settings._wrapped._explicit_settings.remove('MIDDLEWARE_CLASSES') - try: - errors = check_1_7_compatibility() - expected = [ - checks.Warning( - "MIDDLEWARE_CLASSES is not set.", - hint=("Django 1.7 changed the global defaults for the MIDDLEWARE_CLASSES. " - "django.contrib.sessions.middleware.SessionMiddleware, " - "django.contrib.auth.middleware.AuthenticationMiddleware, and " - "django.contrib.messages.middleware.MessageMiddleware were removed from the defaults. " - "If your project needs these middleware then you should configure this setting."), - obj=None, - id='1_7.W001', - ) - ] - self.assertEqual(errors, expected) - finally: - # Restore settings value - if middleware_classes_overridden: - settings._wrapped._explicit_settings.add('MIDDLEWARE_CLASSES') - - def simple_system_check(**kwargs): simple_system_check.kwargs = kwargs return [] diff --git a/tests/runtests.py b/tests/runtests.py index 0469d83600..fe3049dfa4 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -135,8 +135,6 @@ def setup(verbosity, test_labels): settings.LANGUAGE_CODE = 'en' settings.SITE_ID = 1 settings.MIDDLEWARE_CLASSES = ALWAYS_MIDDLEWARE_CLASSES - # Ensure the middleware classes are seen as overridden otherwise we get a compatibility warning. - settings._explicit_settings.add('MIDDLEWARE_CLASSES') settings.MIGRATION_MODULES = { # these 'tests.migrations' modules don't actually exist, but this lets # us skip creating migrations for the test models.