def test_disable_exception_swallowing_function(): raised = CustomException() with pytest.raises(CustomException) as caught: with exception_handling.get_exception_swallowing_context(): exception_handling.disable_exception_swallowing(raised) raise raised assert caught.value is raised
def test_disable_exception_swallowing_decorator(): raised = CustomException() @exception_handling.disable_exception_swallowing def func(): raise raised with pytest.raises(CustomException) as caught: with exception_handling.get_exception_swallowing_context(): func() assert caught.value is raised
def assertNoSwallow(self): raised = CustomException() with self.assertRaises(CustomException) as caught: with exception_handling.get_exception_swallowing_context(): yield raised self.assertIs(raised, caught.exception)
def test_swallow(self): with exception_handling.get_exception_swallowing_context(): raise CustomException("!!!")
def test_no_swallow(): raised = CustomException() with pytest.raises(CustomException) as caught: with exception_handling.get_exception_swallowing_context(): raise exception_handling.noswallow(raised) assert raised is caught.value
def test_swallow_exceptions(): with exception_handling.get_exception_swallowing_context(): raise CustomException("!!!")