schrodinger.test.decorate_fflag module

Enable or disable a feature flag in a specific situation. Can be used as a decorator for a TestCase class or a test function, or as a context manager. See nose_plugin_test.py for examples. Multiple feature flag toggling decorators/contexts can be nested to define desired feature flag environment.

@copyright: (c) Schrodinger, LLC All rights reserved.

class schrodinger.test.decorate_fflag.enable_feature_flag(flag)[source]

Bases: contextlib.ContextDecorator

Provides a decorator/context manager for enabling feature flags. Methods are named to allow this to be used the same ways as Mock’s patches:

  • As context manager

  • As function or test class decorator

  • Explicit start and stop.

on = 1
__init__(flag)[source]
start()[source]

Starts the patching. Used both in the decorator and the context manager.

stop()[source]

Stops the patching. Used both in the decorator context and the context manager context.

class schrodinger.test.decorate_fflag.disable_feature_flag(flag)[source]

Bases: schrodinger.test.decorate_fflag.enable_feature_flag

Disable a feature flag as either a context manager or a decorator for a unittest.TestCase or a test function. :type flag: str :param flag: Name of the feature flag to be disabled.

on = 0
__init__(flag)
start()

Starts the patching. Used both in the decorator and the context manager.

stop()

Stops the patching. Used both in the decorator context and the context manager context.