def test_tracebackFromCleanFailure(self): """ Errors added through the L{PyUnitResultAdapter} have the same traceback information as if there were no adapter at all, even if the Failure that held the information has been cleaned. """ try: 1 / 0 except ZeroDivisionError: exc_info = sys.exc_info() f = Failure() f.cleanFailure() pyresult = pyunit.TestResult() result = PyUnitResultAdapter(pyresult) result.addError(self, f) self.assertEqual(pyresult.errors[0][1], "".join(traceback.format_exception(*exc_info)))
def test_tracebackFromCleanFailure(self): """ Errors added through the L{PyUnitResultAdapter} have the same traceback information as if there were no adapter at all, even if the Failure that held the information has been cleaned. """ try: 1/0 except ZeroDivisionError: exc_info = sys.exc_info() f = Failure() f.cleanFailure() pyresult = pyunit.TestResult() result = PyUnitResultAdapter(pyresult) result.addError(self, f) self.assertEqual(pyresult.errors[0][1], ''.join(traceback.format_exception(*exc_info)))
def test_cleanedFailure(self): """ A cleaned Failure object has a fake traceback object; make sure that logging such a failure still results in the exception details being logged. """ def failing_func(): 1 / 0 try: failing_func() except ZeroDivisionError: failure = Failure() failure.cleanFailure() event = dict(log_format='Hi mom', who='me', log_failure=failure) records, output = self.logEvent(event) self.assertEqual(len(records), 1) self.assertIn(u'Hi mom', output) self.assertIn(u'in failing_func', output) self.assertIn(u'ZeroDivisionError', output)