This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author osdiab
Recipients ezio.melotti, michael.foord, osdiab, pitrou, py.user
Date 2015-11-18.01:34:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1447810492.89.0.625871066666.issue18848@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-11-18 01:34:53osdiabsetrecipients: + osdiab, pitrou, ezio.melotti, michael.foord, py.user
2015-11-18 01:34:52osdiabsetmessageid: <1447810492.89.0.625871066666.issue18848@psf.upfronthosting.co.za>
2015-11-18 01:34:52osdiablinkissue18848 messages
2015-11-18 01:34:52osdiabcreate