def test_excInfo(self): """ L{excInfoOrFailureToExcInfo} returns exactly what it is passed, if it is passed a tuple like the one returned by L{sys.exc_info}. """ info = (ValueError, ValueError("foo"), None) self.assertTrue(info is excInfoOrFailureToExcInfo(info))
def addFailure(self, test, err): """ Record that C{test} failed an assertion with the error C{err}. Also marks the run as being unsuccessful, causing L{SubunitReporter.wasSuccessful} to return C{False}. """ self._successful = False return self._subunit.addFailure(test, util.excInfoOrFailureToExcInfo(err))
def addFailure(self, test, err): """ Record that ``test`` failed an assertion with the error ``err``. """ self.progress_stream.write(self._FAIL_MARK) return self._subunit.addFailure( test, excInfoOrFailureToExcInfo(err), )
def addExpectedFailure(self, test, failure, todo): """ Record an expected failure from a test. """ self.progress_stream.write(self._XFAIL_MARK) self._subunit.addExpectedFailure( test, excInfoOrFailureToExcInfo(failure), )
def addError(self, test, err): """ Record that ``test`` failed with an unexpected error ``err``. """ self.progress_stream.write(self._ERROR_MARK) return self._subunit.addError( test, excInfoOrFailureToExcInfo(err), )
def __init__(self, description, error): """ @param description: A string used by C{TestResult}s to identify this error. Generally, this is the name of a module that failed to import. @param error: The error to be added to the result. Can be an `exc_info` tuple or a L{twisted.python.failure.Failure}. """ super(ErrorHolder, self).__init__(description) self.error = util.excInfoOrFailureToExcInfo(error)
def run(self, result): """ Run the test, reporting the error. @param result: The C{TestResult} to store the results in. @type result: L{twisted.trial.itrial.ITestResult}. """ result.startTest(self) result.addError(self, util.excInfoOrFailureToExcInfo(self.error)) result.stopTest(self)
def test_failure(self): """ When called with a L{Failure} instance, L{excInfoOrFailureToExcInfo} returns a tuple like the one returned by L{sys.exc_info}, with the elements taken from the type, value, and traceback of the failure. """ try: 1 / 0 except: f = Failure() self.assertEqual((f.type, f.value, f.tb), excInfoOrFailureToExcInfo(f))
def addExpectedFailure(self, test, failure, todo=None): """ Record an expected failure from a test. Some versions of subunit do not implement this. For those versions, we record a success. """ failure = util.excInfoOrFailureToExcInfo(failure) addExpectedFailure = getattr(self._subunit, "addExpectedFailure", None) if addExpectedFailure is None: self.addSuccess(test) else: addExpectedFailure(test, failure)
def addExpectedFailure(self, test, failure, todo): """ Record an expected failure from a test. Some versions of subunit do not implement this. For those versions, we record a success. """ failure = util.excInfoOrFailureToExcInfo(failure) addExpectedFailure = getattr(self._subunit, 'addExpectedFailure', None) if addExpectedFailure is None: self.addSuccess(test) else: addExpectedFailure(test, failure)
def _exc_info(self, err): return util.excInfoOrFailureToExcInfo(err)