[TIP] Fwd: cleanUp for unittest

Olemis Lang olemis at gmail.com
Fri Apr 3 13:54:18 PDT 2009

On Fri, Apr 3, 2009 at 3:45 PM, Fred Drake <fdrake at gmail.com> wrote:
> On Fri, Apr 3, 2009 at 4:25 PM, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
>> Well, on the feature under discussion Zope, Twisted and Bzr have all
>> provided it without modifying TestCase but have had to write a lot more
>> code as a result...
> Most important is that code that can't assume the feature is available
> can't use it, unless it can also arrange for the corresponding cleanup
> phase itself (IOW, re-implement the feature).
> We often have packages that provide testing support for client code,
> and that wants to register cleanup functions.  Even with a custom
> TestCase class (which zope.testing doesn't provide, for reasons
> unknown to me),

... and it seems it *should* ... ;)

> this requires that libraries require client code to be
> run

No ... it requires that instead of subclassing unittest.TestCase they
extend zope.testing.ResourceAllocTestCase ...

> with the specialized TestCase.  This might be acceptable, but
> that's not entirely clear to me.

Take a look at dutest.DocTestLoader, dutest.DocTestCase and
dutest.DocTestSuite, and dutest._Doc2UnittestTestRunner classes ...
that's exactly what they do with respect to doctest, actually wrapping
(... adapter pattern applied twice ...) std DocTestRunner class, and
test finders, and so on ... therefore ...

> A great deal of value comes from this being part of the TestCase
> contract out of the box.

... I insist ... I dont see why modifying TestCase is *THE RIGHT*
solution ... I'll tell u more details later ...



Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

More information about the testing-in-python mailing list