summaryrefslogtreecommitdiff
path: root/django/core/checks
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2013-06-25 09:37:54 +0800
committerRussell Keith-Magee <russell@keith-magee.com>2013-06-25 09:37:54 +0800
commit0346563939396fb89dec8df31f82eaefaaeb8616 (patch)
treeb49b3365dabdf61f55a54ded7cb4516d62c352e7 /django/core/checks
parent5a6f12182ef14883df6534dc3465059b78f54a1c (diff)
Fixed #20653 -- Renamed checksetup management command.
This is to allow future compatibility with work that is ongoing in the 2013 GSoC.
Diffstat (limited to 'django/core/checks')
-rw-r--r--django/core/checks/__init__.py0
-rw-r--r--django/core/checks/compatibility/__init__.py0
-rw-r--r--django/core/checks/compatibility/base.py39
-rw-r--r--django/core/checks/compatibility/django_1_6_0.py37
4 files changed, 76 insertions, 0 deletions
diff --git a/django/core/checks/__init__.py b/django/core/checks/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/django/core/checks/__init__.py
diff --git a/django/core/checks/compatibility/__init__.py b/django/core/checks/compatibility/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/django/core/checks/compatibility/__init__.py
diff --git a/django/core/checks/compatibility/base.py b/django/core/checks/compatibility/base.py
new file mode 100644
index 0000000000..7fe52d2af9
--- /dev/null
+++ b/django/core/checks/compatibility/base.py
@@ -0,0 +1,39 @@
+from __future__ import unicode_literals
+import warnings
+
+from django.core.checks.compatibility import django_1_6_0
+
+
+COMPAT_CHECKS = [
+ # Add new modules at the top, so we keep things in descending order.
+ # After two-three minor releases, old versions should get dropped.
+ django_1_6_0,
+]
+
+
+def check_compatibility():
+ """
+ Runs through compatibility checks to warn the user with an existing install
+ about changes in an up-to-date Django.
+
+ Modules should be located in ``django.core.compat_checks`` (typically one
+ per release of Django) & must have a ``run_checks`` function that runs
+ all the checks.
+
+ Returns a list of informational messages about incompatibilities.
+ """
+ messages = []
+
+ for check_module in COMPAT_CHECKS:
+ check = getattr(check_module, 'run_checks', None)
+
+ if check is None:
+ warnings.warn(
+ "The '%s' module lacks a " % check_module.__name__ +
+ "'run_checks' method, which is needed to verify compatibility."
+ )
+ continue
+
+ messages.extend(check())
+
+ return messages
diff --git a/django/core/checks/compatibility/django_1_6_0.py b/django/core/checks/compatibility/django_1_6_0.py
new file mode 100644
index 0000000000..1998c5ba77
--- /dev/null
+++ b/django/core/checks/compatibility/django_1_6_0.py
@@ -0,0 +1,37 @@
+from __future__ import unicode_literals
+
+
+def check_test_runner():
+ """
+ Checks if the user has *not* overridden the ``TEST_RUNNER`` setting &
+ warns them about the default behavior changes.
+
+ If the user has overridden that setting, we presume they know what they're
+ doing & avoid generating a message.
+ """
+ from django.conf import settings
+ new_default = 'django.test.runner.DiscoverRunner'
+ test_runner_setting = getattr(settings, 'TEST_RUNNER', new_default)
+
+ if test_runner_setting == new_default:
+ message = [
+ "You have not explicitly set 'TEST_RUNNER'. In Django 1.6,",
+ "there is a new test runner ('%s')" % new_default,
+ "by default. You should ensure your tests are still all",
+ "running & behaving as expected. See",
+ "https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module",
+ "for more information.",
+ ]
+ return ' '.join(message)
+
+
+def run_checks():
+ """
+ Required by the ``check`` management command, this returns a list of
+ messages from all the relevant check functions for this version of Django.
+ """
+ checks = [
+ check_test_runner()
+ ]
+ # Filter out the ``None`` or empty strings.
+ return [output for output in checks if output]