Test Utilities¶
-
class
gargoyle.testutils.
SwitchContextManager
(gargoyle=<SimpleLazyObject: <function make_gargoyle at 0x7fbb880fd0c8>>, **keys)¶ Allows temporarily enabling or disabling a switch.
Ideal for testing.
>>> @switches(my_switch_name=True) >>> def foo(): >>> print(gargoyle.is_active('my_switch_name'))
>>> def foo(): >>> with switches(my_switch_name=True): >>> print(gargoyle.is_active('my_switch_name'))
You may also optionally pass an instance of
SwitchManager
as the first argument.>>> def foo(): >>> with switches(gargoyle, my_switch_name=True): >>> print(gargoyle.is_active('my_switch_name'))