django-configurations
django-configurations copied to clipboard
django-configurations is incompatible with `modify_settings` and `override_settings` decorators
# …/settings.py
from configurations import Configuration
class MyConfiguration(Configuration):
DEBUG = False
# …
# …/test_thing.py
from django.test import modify_settings
@modify_settings(DEBUG=True)
def test_settings():
from django.conf import settings
assert hasattr(settings, "DEBUG")
assert settings.DEBUG
Running the above test will blow up here with the error TypeError: 'bool' object is not iterable. This makes sense, looking at the code:
try:
# When called from SimpleTestCase.setUpClass, values may be
# overridden several times; cumulate changes.
value = self.options[name]
except KeyError:
value = list(getattr(settings, name, [])) # <-- Boom!
In that context, getattr(settings, name, …) gets the value of MyConfiguration.DEBUG, which is False.
That's a good find.