From fa89e5d382517dc531e3cc0b32b6ed91902a3946 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Tue, 21 Nov 2023 12:32:21 +0100 Subject: [PATCH] tests:utils - test allow argument of ExceptionManager --- tests/test_utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 7446b6c..a5083fc 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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