[TIP] subclassing TestSuite to override __iter__ is painful

Robert Collins robertc at robertcollins.net
Mon Apr 6 14:38:44 PDT 2009


On Mon, 2009-04-06 at 08:48 -0500, Olemis Lang wrote:
> On Sat, Apr 4, 2009 at 5:03 PM, Robert Collins
> <robertc at robertcollins.net> wrote:
> > I've put a patch up here http://bugs.python.org/issue5693. In short, a
> > TestSuite whose __iter__ does something more complex (such as test
> > discover) requires you to reimplement nearly everything rather than just
> > __iter__ and addTest. This makes it a lot simpler.
> >
> 
> Didnt see the patch but AFAIK ... test suites are there only to group
> test cases ... not to perform test discovery (that's loaders business
> ...)

TestSuite/TestCase are a Composite in the GoF pattern language; as such
TestSuite can do a lot more than group tests (and in fact grouping is
almost entirely useless). TestSuite is delegated to when you run tests,
and can safely do things like randomising order, managing common
resources and more.

> I see there are strong influences in order to change XUnit paradigm in
> Python. Pls, I beg you ... if you are going to improve the lib, at
> least keep the spirit and the foundations of the original framework.

I'm a strong advocate of the base framework - if you look at my
extensions I think you'll find they all leverage the core design
cleanly. [e.g. subunit, testresources, testscenarios].
...

> CMIIW ... anyway ... maybe I'm wrong, but TestSuite(s) should group
> test cases, and nothing beyond that ... If complex groupings are
> needed (e.g. dutest.DocTestSuite), pls, write a separate subclass, and
> that's it ...
> 
> This is IMHO ... ;)

The patch that you haven't seen makes it simpler to write a subclass,
thats all.

-Rob

-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.idyll.org/pipermail/testing-in-python/attachments/20090407/e55800ce/attachment.pgp 


More information about the testing-in-python mailing list