summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2016-01-25 14:27:35 -0500
committerSimon Charette <charette.s@gmail.com>2016-01-25 21:38:36 -0500
commit4dcaa5871b70859952c6f9c437dfe1b5f10509f2 (patch)
treeb67b44293702762314d86f7d625588c69acb1ca1
parent229488c8a1486f25b1f2b5ca422cac67708c6c9d (diff)
Fixed #26135 -- Adjusted the migration questioner's handling of disabled apps.
This was causing an issue when calling the `migrate` command in a test case with the `available_apps` attribute pointing to an application with migrations disabled using the `MIGRATION_MODULES` setting. Thanks to Tim Graham for the review. Refs #24919
-rw-r--r--django/db/migrations/questioner.py3
-rw-r--r--docs/releases/1.9.2.txt4
-rw-r--r--tests/migrations/test_questioner.py15
3 files changed, 22 insertions, 0 deletions
diff --git a/django/db/migrations/questioner.py b/django/db/migrations/questioner.py
index aef80f4a52..47d4cdf130 100644
--- a/django/db/migrations/questioner.py
+++ b/django/db/migrations/questioner.py
@@ -38,6 +38,9 @@ class MigrationQuestioner(object):
except LookupError: # It's a fake app.
return self.defaults.get("ask_initial", False)
migrations_import_path = MigrationLoader.migrations_module(app_config.label)
+ if migrations_import_path is None:
+ # It's an application with migrations disabled.
+ return self.defaults.get("ask_initial", False)
try:
migrations_module = importlib.import_module(migrations_import_path)
except ImportError:
diff --git a/docs/releases/1.9.2.txt b/docs/releases/1.9.2.txt
index e64c62e3da..1612a938a2 100644
--- a/docs/releases/1.9.2.txt
+++ b/docs/releases/1.9.2.txt
@@ -71,3 +71,7 @@ Bugfixes
* Fixed a crash when using a reverse ``OneToOneField`` in
``ModelAdmin.readonly_fields`` (:ticket:`26060`).
+
+* Fixed a crash when calling the ``migrate`` command in a test case with the
+ ``available_apps`` attribute pointing to an application with migrations
+ disabled using the ``MIGRATION_MODULES`` setting (:ticket:`26135`).
diff --git a/tests/migrations/test_questioner.py b/tests/migrations/test_questioner.py
new file mode 100644
index 0000000000..d5ba18a684
--- /dev/null
+++ b/tests/migrations/test_questioner.py
@@ -0,0 +1,15 @@
+from __future__ import unicode_literals
+
+from django.db.migrations.questioner import MigrationQuestioner
+from django.test import SimpleTestCase
+from django.test.utils import override_settings
+
+
+class QuestionerTests(SimpleTestCase):
+ @override_settings(
+ INSTALLED_APPS=['migrations'],
+ MIGRATION_MODULES={'migrations': None},
+ )
+ def test_ask_initial_with_disabled_migrations(self):
+ questioner = MigrationQuestioner()
+ self.assertIs(False, questioner.ask_initial('migrations'))