예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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
예제 #5
0
 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)
예제 #6
0
 def test_swallow(self):
     with exception_handling.get_exception_swallowing_context():
         raise CustomException("!!!")
예제 #7
0
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
예제 #8
0
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
예제 #9
0
def test_swallow_exceptions():
    with exception_handling.get_exception_swallowing_context():
        raise CustomException("!!!")
예제 #10
0
 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)