Author ezio.melotti
Recipients bennoleslie, ezio.melotti, michael.foord, rbcollins
Date 2015-12-31.00:26:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1451521593.04.0.856660592589.issue25687@psf.upfronthosting.co.za>
In-reply-to
Content
This happens because TestCase.run (Lib/unittest/case.py:595) runs setUp/test/tearDown in 3 separate testPartExecutor context manager  (Lib/unittest/case.py:54).  testPartExecutor appends any error to self.errors (Lib/unittest/case.py:72) and TextTestRunner.run simply reports the total number of errors Lib/unittest/runner.py:204).
If an error happens in the setUp, the test and tearDown are not executed, but if it happens in the test, the tearDown is still executed, possibly appending a second error to self.errors.

I don't see any easy way to fix this, since both errors should stay in self.errors and be reported, so removing one is not an option.  Trying to determine if 2 errors are related to a single test/tearDown pair in the TestRunner might be possible, but probably not worth it.

Adding a sentence to the doc and possibly a comment in TestCase.run to document this corner case is probably enough.
History
Date User Action Args
2015-12-31 00:26:33ezio.melottisetrecipients: + ezio.melotti, rbcollins, michael.foord, bennoleslie
2015-12-31 00:26:33ezio.melottisetmessageid: <1451521593.04.0.856660592589.issue25687@psf.upfronthosting.co.za>
2015-12-31 00:26:33ezio.melottilinkissue25687 messages
2015-12-31 00:26:32ezio.melotticreate