Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-configurations is incompatible with modify_settings and override_settings decorators #334

Open
posita opened this issue May 20, 2022 · 1 comment

Comments

@posita
Copy link

posita commented May 20, 2022

# …/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.

@lino
Copy link

lino commented Jul 18, 2022

That's a good find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants