Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 6
0
 def test_swallow(self):
     with exception_handling.get_exception_swallowing_context():
         raise CustomException("!!!")
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 9
0
def test_swallow_exceptions():
    with exception_handling.get_exception_swallowing_context():
        raise CustomException("!!!")
Exemplo n.º 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)