[TIP] testtools MultiTestResult

Robert Collins robertc at robertcollins.net
Fri Oct 15 12:56:02 PDT 2010

On Sat, Oct 16, 2010 at 12:22 AM, Michael Foord
<fuzzyman at voidspace.org.uk> wrote:
>  On 15/10/2010 12:05, Jonathan Lange wrote:
>> On Fri, Oct 15, 2010 at 11:48 AM, Michael Foord
>> <michael at voidspace.org.uk>  wrote:
>>>  On 15/10/2010 11:46, Jonathan Lange wrote:
>>>> On Fri, Oct 15, 2010 at 11:35 AM, Michael Foord
>>>> <michael at voidspace.org.uk>    wrote:
>>>>>  Hello testing in Python folk,
>>>>> Is the testtools MultiTestResult documented anywhere?
>>>> There's a class docstring. That's it.
>>>>> If it *is* may I suggest better documentation links on the PyPI and
>>>>> launchpad pages. If it isn't, grrrrr...
>>>> I'll try to make it better sometime soon –
>>>> https://bugs.edge.launchpad.net/testtools/+bug/661116. Ideally, I'd
>>>> love someone with the energy and wherewithal to maintain live API docs
>>>> from trunk&    latest release. The cron job I set up myself stopped
>>>> working weeks ago and has been on my "to do" list since.
>>>> FWIW, you just give the constructor a bunch of TestResults and then
>>>> MultiTR forwards the events it receives on to each of those
>>>> TestResults.
>>> Thanks.
>>>  From looking at the code, as far as I can see testtools only provides
>>> TestResult objects and none that derive from _TextTestResult. Even the
>>> testtools TextTestResult doesn't derive from _TextTestResult.
>>> The unittest test runner is TextTestRunner. This *requires* a
>>> _TextTestResult because the test runner calls result.printErrors.
>>> (Questioning the wisdom of that is perfectly valid but long pre-dates my
>>> involvement....)
>>> It seems I can't use any of the testtools result objects with the
>>> standard
>>> unittest test runner. :-(
>> The main reasons none of the result objects support it are because
>> none of testtools' users (vast horde that they are) have asked for it.
> That's a perfectly valid reason. :-) It just happens that MultiTestResult
> would have been ideal for me, but I'm using the standard TextTestRunner
> (actually via django) so can't use it. Oh well. :-)


class MultiTextTestResult(MultiTestResult):
    def printErrors(self):
        return self._dispatch('printErrors')


More information about the testing-in-python mailing list