From a738bf5a88bba265286838a9ece66ddb7c817edf Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Tue, 16 Jan 2024 17:39:16 +0300 Subject: [PATCH] tests --- tests/units/tokens/test_condition_token.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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]