Message254826
I found out about this while writing my own test runner, and investigated it in an answer to a StackOverflow question here: https://stackoverflow.com/questions/32920025/how-do-i-use-unittest-testresult/33770125#33770125
The startTestRun() method is supposed to be called at the beginning of a test run. That mostly works, but if you run a TestCase.run() method—or TestSuite.run(), because it just calls TestCase.run()—it will only call that method if you don't provide a TestResult instance. That means the lifecycle method is useless in those cases, because the default TestResult.startTestRun() method is a no-op.
This is how unittest.TestCase.run() starts:
def run(self, result=None):
orig_result = result
if result is None:
result = self.defaultTestResult()
startTestRun = getattr(result, 'startTestRun', None)
if startTestRun is not None:
startTestRun()
# ...
The branch for calling startTestRun() is inside the `if result is None` check, making it never get called with an implementation of startTestRun().
This is currently mitigatable by just calling startTestRun() manually. But the documentation makes it seem like this lifecycle method should be called automatically, when it is not. |
|
Date |
User |
Action |
Args |
2015-11-18 01:34:53 | osdiab | set | recipients:
+ osdiab, pitrou, ezio.melotti, michael.foord, py.user |
2015-11-18 01:34:52 | osdiab | set | messageid: <1447810492.89.0.625871066666.issue18848@psf.upfronthosting.co.za> |
2015-11-18 01:34:52 | osdiab | link | issue18848 messages |
2015-11-18 01:34:52 | osdiab | create | |
|