Skip to content

Commit

Permalink
tests:utils - test allow argument of ExceptionManager
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Nov 21, 2023
1 parent 66f526f commit fa89e5d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,25 @@ def test_helpers():
assert context.exception.code == 3
assert context.traceback is not None

with pytest.raises(KeyboardInterrupt) as raises, ExceptionManager(Exception) as context:
with (
pytest.raises(KeyboardInterrupt) as raises,
ExceptionManager(Exception) as context,
):
raise KeyboardInterrupt

assert isinstance(raises.value, KeyboardInterrupt)
assert isinstance(context.exception, KeyboardInterrupt)
assert context.traceback is not None

with (
pytest.raises(OSError) as raises, # noqa: PT011
ExceptionManager(BaseException, allow=[OSError]) as context,
):
raise FileNotFoundError

assert isinstance(raises.value, FileNotFoundError)
assert isinstance(context.exception, FileNotFoundError)

with ExceptionManager() as context:
pass

Expand Down

0 comments on commit fa89e5d

Please sign in to comment.