[TIP] Best way to do setup/teardown on a per-test basis using doctest?

Benji York benji at benjiyork.com
Mon Jul 2 06:29:53 PDT 2007


If you want several set up and tear down cycles in a single doctest I 
would suggest the footnote addition we made to doctest.  (I _really_ 
need to spend some time deforking our version).

On the other hand, it sounds like you don't really want a traditional 
setup because the things being set up are important to understanding the 
intention and meaning of the tests, so they should probably be included 
in the test itself.  The tear down is much less important, so a footnote 
or test-wide tear down would be more appropriate there.

Brett Cannon wrote:
> But how do I guarantee that the teardown is called?  If do something like::

The callable passed in the tearDown argument to DocFileSuite is always 
called.
-- 
Benji York
http://benjiyork.com



More information about the testing-in-python mailing list