diff options
| author | SusanTan <onceuponatimeforever@gmail.com> | 2013-08-07 01:07:16 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-08-09 08:08:34 -0400 |
| commit | 2ac89012d8ff750ea5443b6f6f347dacb697e059 (patch) | |
| tree | b1684f43c1c344991f3700073481cdde7e046c92 | |
| parent | 4fa2738ff3ff2704140c8bcb6671d76e9f31f776 (diff) | |
Fixed #12288 -- Added unique validation for INSTALLED_APPS
| -rw-r--r-- | django/conf/__init__.py | 3 | ||||
| -rw-r--r-- | tests/settings_tests/tests.py | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py index 56d9ab21c9..e628af748c 100644 --- a/django/conf/__init__.py +++ b/django/conf/__init__.py @@ -107,6 +107,9 @@ class BaseSettings(object): elif name == "ALLOWED_INCLUDE_ROOTS" and isinstance(value, six.string_types): raise ValueError("The ALLOWED_INCLUDE_ROOTS setting must be set " "to a tuple, not a string.") + elif name == "INSTALLED_APPS" and len(value) != len(set(value)): + raise ImproperlyConfigured("The INSTALLED_APPS setting must contain unique values.") + object.__setattr__(self, name, value) diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py index 3673031447..4031d09a58 100644 --- a/tests/settings_tests/tests.py +++ b/tests/settings_tests/tests.py @@ -226,6 +226,27 @@ class TestComplexSettingOverride(TestCase): self.assertEqual('Overriding setting TEST_WARN can lead to unexpected behaviour.', str(w[-1].message)) +class UniqueSettngsTests(TestCase): + """ + Tests for the INSTALLED_APPS setting. + """ + settings_module = settings + + def setUp(self): + self._installed_apps = self.settings_module.INSTALLED_APPS + + def tearDown(self): + self.settings_module.INSTALLED_APPS = self._installed_apps + + def test_unique(self): + """ + An ImproperlyConfigured exception is raised if the INSTALLED_APPS contains + any duplicate strings. + """ + with self.assertRaises(ImproperlyConfigured): + self.settings_module.INSTALLED_APPS = ("myApp1", "myApp1", "myApp2", "myApp3") + + class TrailingSlashURLTests(TestCase): """ Tests for the MEDIA_URL and STATIC_URL settings. |
