diff --git a/tests/units/tokens/test_condition_token.py b/tests/units/tokens/test_condition_token.py index ad5f960..ad92ab7 100644 --- a/tests/units/tokens/test_condition_token.py +++ b/tests/units/tokens/test_condition_token.py @@ -270,3 +270,25 @@ def after_callback(): token.check() assert lst == [1, 2, 3] + + +def test_raise_not_suppressed_exception_in_before_callback(): + lst = [] + + token = ConditionToken(lambda: lst.append(2) is not None, before=lambda: 1 / 0, suppress_exceptions=False) + + with pytest.raises(ZeroDivisionError): + token.check() + + assert not lst + + +def test_raise_not_suppressed_exception_in_after_callback(): + lst = [] + + token = ConditionToken(lambda: lst.append(2) is not None, before=lambda: lst.append(1), after=lambda: 1 / 0, suppress_exceptions=False) + + with pytest.raises(ZeroDivisionError): + token.check() + + assert lst == [1, 2]