Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Jan 16, 2024
1 parent 8a2c1a5 commit a738bf5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/units/tokens/test_condition_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit a738bf5

Please sign in to comment.