Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #12288 -- Added unique validation for INSTALLED_APPS

  • Loading branch information...
commit 2ac89012d8ff750ea5443b6f6f347dacb697e059 1 parent 4fa2738
@onceuponatimeforever onceuponatimeforever authored timgraham committed
Showing with 24 additions and 0 deletions.
  1. +3 −0  django/conf/__init__.py
  2. +21 −0 tests/settings_tests/tests.py
View
3  django/conf/__init__.py
@@ -107,6 +107,9 @@ def __setattr__(self, name, value):
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)
View
21 tests/settings_tests/tests.py
@@ -226,6 +226,27 @@ def test_complex_override_warning(self):
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.

0 comments on commit 2ac8901

Please sign in to comment.
Something went wrong with that request. Please try again.