コード例 #1
0
    def test_current_overrides_returns_active_context(self, never):
        manager = OverrideManager()
        o = Override(never)

        manager.push(o)

        assert o == current_overrides

        manager.pop()
コード例 #2
0
    def test_manager_throws_if_different_context_popped(self):
        manager = OverrideManager()
        manager.push(Override())
        manager2 = OverrideManager()

        with pytest.raises(RuntimeError) as excinfo:
            manager2.pop()

        assert "popped wrong override context" in str(excinfo.value)
コード例 #3
0
def test_conditional_skips_overridden_requirements(member, never, always, request):
    manager = OverrideManager()
    manager.push(Override(never))

    reqs = And(never, always)

    assert reqs.fulfill(member, request)

    manager.pop()
コード例 #4
0
    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()
コード例 #5
0
def test_conditional_skips_overridden_requirements_even_if_nested(
    member, always, never, request
):
    manager = OverrideManager()
    manager.push(Override(never))

    reqs = And(And(And(always), Or(never)))

    assert reqs.fulfill(member)

    manager.pop()
コード例 #6
0
 def test_override_manager_populates_overrides_local(self):
     manager = OverrideManager()
     override = Override(some_requirement)
     manager.push(override)
     assert some_requirement in current_overrides