Skip to content

Wanted: context manager to temporarily override a flag #84

@chosak

Description

@chosak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions