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

Already on GitHub? Sign in to your account

SwitchContextManager doesn't work with hierarchical switches #34

Open
mbox opened this Issue Apr 2, 2012 · 1 comment

Comments

Projects
None yet
2 participants

mbox commented Apr 2, 2012

The syntax for SwitchContextManager is with switches(my_switch_name=True):, which requires my_switch_name to be a valid Python identifier.

Hierarchical switches use ":" to separate path components - which isn't a valid character in an identifier.

mbox added a commit to tellybug/gargoyle that referenced this issue Apr 2, 2012

Fix for issue #34: SwitchContextManager doesn't work with hierarchica…
…l switches

Adds support for a "switches" kwarg on the decorator - if the switch name is
not a valid ID you can use @switches(switches={'test🅰️hierarchy': True}) to set
the default value

acdha commented Aug 27, 2012

I just ran into this & ended up using mock.patch to force the values I needed:

@patch("gargoyle.gargoyle.is_active", return_value=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment