Exemplo n.º 1
0
 def test_trapReturns(self):
     """
     The C{trap} method is like C{check} in that it returns the passed
     exception type that matches the failure's value.
     """
     failure = SynchronousFailure(RuntimeError())
     self.assertEquals(failure.trap(ZeroDivisionError, RuntimeError),
                       RuntimeError)
Exemplo n.º 2
0
 def test_check(self):
     """
     Check accepts multiple exception types, and returns the exception type
     which matched.
     """
     failure = SynchronousFailure(RuntimeError())
     self.assertEquals(failure.check(ZeroDivisionError, RuntimeError),
                       RuntimeError)
Exemplo n.º 3
0
 def test_getExceptionFromEnvironment(self):
     """
     SynchronousFailure infers the current exception and traceback from the
     environment.
     """
     try:
         1/0
     except:
         failure = SynchronousFailure()
     self.assertTrue(failure.check(ZeroDivisionError))
Exemplo n.º 4
0
    def test_raiseException(self):
        """
        C{raiseException} raises the original exception, including traceback.
        """
        try:
            1/0
        except:
            failure = SynchronousFailure()

        try:
            failure.raiseException()
        except ZeroDivisionError, e:
            tb = traceback.extract_tb(sys.exc_info()[2])
            innerline = tb[-1][-1]
Exemplo n.º 5
0
 def test_passInException(self):
     """
     SynchronousFailure takes an Exception instance as its parameter.
     """
     failure = SynchronousFailure(RuntimeError("hello"))
     self.assertTrue(failure.check(RuntimeError))