Ezio Melotti added the comment: 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. ---------- keywords: +easy stage: -> needs patch versions: -Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25687> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com