Message257243
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. |
|
Date |
User |
Action |
Args |
2015-12-31 00:26:33 | ezio.melotti | set | recipients:
+ ezio.melotti, rbcollins, michael.foord, bennoleslie |
2015-12-31 00:26:33 | ezio.melotti | set | messageid: <1451521593.04.0.856660592589.issue25687@psf.upfronthosting.co.za> |
2015-12-31 00:26:33 | ezio.melotti | link | issue25687 messages |
2015-12-31 00:26:32 | ezio.melotti | create | |
|