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

Wanted: context manager to temporarily override a flag #84

Open
chosak opened this issue Oct 13, 2021 · 1 comment
Open

Wanted: context manager to temporarily override a flag #84

chosak opened this issue Oct 13, 2021 · 1 comment

Comments

@chosak
Copy link
Member

chosak commented Oct 13, 2021

It would be useful to be able to write code like this:

with override_flag(MY_FLAG=True):
    # do some code that checks the value of MY_FLAG

The tests tend to use Django override_settings for this purpose, but this feels too heavy for inline code that only needs to patch a single flag instead of modifying the entire settings structure (not to mention adding a dependency on "test" code).

I realize this might be complicated because of the way that flag states get cached on the request object, but I suspect that using override_settings wouldn't work there either if the flag states were already cached.

@willbarton
Copy link
Member

That's a really good idea!

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