[TIP] unittest subtests

Robert Collins robertc at robertcollins.net
Sun Jan 20 11:46:41 PST 2013


On 21 January 2013 02:52, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
>
> On 20 Jan 2013, at 00:07, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:
>
>> Just thought I would let this list know about an issue/patch to add a
>> sort of parametrized test functionality to unittest called subtests:
>>
>> http://bugs.python.org/issue16997
>>
>> It would be good to know how the proposed implementation plays with
>> the various test frameworks that are out there.
>
> I also wonder how this will work with reporting tools that integrate unittest with Jenkins continuous integration.
>
> It means the total number of tests can't be known up front (parameterization generates testcases at collection time - sub tests creates the tests dynamically). The number of tests could even be different every run.

Indeed!

Other interactions: testtools extends the 'addError' etc calls to let
arbitrary additional errors or diagnostic data be attached. I don't
think we would care if non-test cases get passed in, because we
already cope with synthetic test case objects being passed in via
subunit streams.

That said, sharing setUp and tearDown seems to make this thing very
special cased and not generally useful. Why not something like (or
even take it verbatim - I'd be happy to contribute it)
http://pypi.python.org/pypi/testscenarios/ ?

-Rob



More information about the testing-in-python mailing list