Jump to >

djblets.features.testing

Helpers for unit tests working with features.

override_feature_checks(*args, **kwds)[source]

Override multiple features for a test.

Unit tests can make use of this context manager to ensure that one or more features have particular enabled/disabled states before executing any code dependent on those features.

Only the provided features will be modified, with all other feature logic falling back to the default behavior for the configured feature checker.

Parameters:feature_states (dict) – A dictionary of feature IDs to booleans (representing whether the feature is enabled).

Example

feature_states = {
    'my-feature-1': True,
    'my-feature-2': False,
}

with override_feature_checks(feature_states):
    # Your test code here.
override_feature_check(*args, **kwds)[source]

Override a feature for a test.

Unit tests can make use of this context manager to ensure that a specific feature has a particular enabled/disabled state before executing any code dependent on that feature.

Only the provided feature will be modified, with all other feature logic falling back to the default behavior for the configured feature checker.

Parameters:
  • feature_id (unicode) – The ID of the feature to override.
  • enabled (bool) – The enabled state for the feature.

Example

with override_feature_check('my-feature', enabled=False):
    # Your test code here.