You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement a pytest plugin to help with testing #135
As part of some work in the core Flagsmith repository, we found that there isn't currently a good, generic solution for mocking the flagsmith client to return a given value for a flag at a given time. The ideal implementation as I see it would be to build a fixture that can be used as a context manager, or a function that looks something like this:
defmy_test_function(set_flags: FlagsmithSetFlagsFixture) ->None:
withoverride_flagsmith(flags=[Flag(name="foo", enabled=True, value="foobar")]):
# in here, any calls to Flags.is_feature_enabled,Flags.get_flag and Flags.get_feature_value # for the feature "foo" will return the values provided as an argument to override_flagsmith
...
defmy_other_test_function(set_flags: FlagsmithSetFlagsFixture) ->None:
set_flags(flags=[Flag(name="foo", enabled=True, value="foobar")])
# For the remainder of this test, any calls to Flags.is_feature_enabled,Flags.get_flag # and Flags.get_feature_value for the feature "foo" will return the values provided as # an argument to override_flagsmith
Activity