示例#1
0
async def test_behavior_reentrance_protection(alice):
    behavior = Behavior(always, SimpleLogic())
    async with behavior.apply(alice):
        with pytest.raises(ValidationError, match="Reentrance: Behavior"):
            async with behavior.apply(alice):
                # this block should not be hit
                raise AssertionError("should not be hit")
示例#2
0
async def test_behavior_logic_reuse_protection_on_apply(alice):
    logic = SimpleLogic()
    behavior_a = Behavior(always, logic)
    behavior_b = Behavior(always, logic)
    async with behavior_a.apply(alice):
        with pytest.raises(ValidationError, match="Reentrance: Logic"):
            async with behavior_b.apply(alice):
                # this block should not be hit
                raise AssertionError("should not be hit")
async def test_behavior_crash(alice):
    behavior = Behavior(always, CrashingLogic())
    async with behavior.apply(alice) as future:
        with pytest.raises(BehaviorCrash):
            await future