Comment 6 for bug 501169

Revision history for this message
Martin Packman (gz) wrote :

> How's this done in stdlib unittest?

As explained already, unittest.TestResult.addError gets the exc_info passed to it as the third argument. With testtools you get a useless string wrapper instead.

> There isn't really such a requirement in unittest proper. Can you
> enlarge on why you feel strongly about this...

You broke my code. I had to write some ridiculous bullshit to get it working again.

A change I needed to make to support testtools:

- def addError(self, test, err):
+ def addError(self, test, err=None, details=None):
+ if err is None:
+ err = sys.exc_info()

And even worse (and the stack is barely useful most of the time here 'cos it's from the wrong place):

- def addExpectedFailure(self, test, err):
+ def addExpectedFailure(self, test, err=None, details=None):
+ if err is None:
+ olderr = sys.exc_info()[1].args[0]
+ if isinstance(olderr, tuple) and len(olderr) == 3:
+ # This is the knock-on ExpectedFailure, but it's passed the
+ # original exc_info for some reason, so get that back
+ err = olderr
+ else:
+ # The ExpectedFailure was manually raised
+ err = sys.exc_info()

Let me revert that and I'll be happy again.