def test_override_with_use_parent_combines_both(self): manager = OverrideManager() def parent_requirement(user): return True def child_requirement(user): return True parent = Override(parent_requirement) child = Override(child_requirement) expected = Override(parent_requirement, child_requirement) with manager.override(parent): with manager.override(child, use_parent=True): assert expected == manager.current
def test_override_context_manager(self): manager = OverrideManager() o = Override() with manager.override(o): assert _override_ctx_stack.top[1] is o assert _override_ctx_stack.top is None
def test_current_overrides_points_towards_temporary_context( self, never, always): manager = OverrideManager() manager.push(Override(never)) o = Override(always) with manager.override(o): assert o == current_overrides manager.pop()