[TIP] always call teardownX even if setupX fails?

Robert Collins robertc at robertcollins.net
Wed Jan 27 13:19:03 PST 2010


On Wed, 2010-01-27 at 18:07 +0100, holger krekel wrote:
> 
> > Any test with moderately complex external fixtures would benefit
> from  
> > this behavior.  We use a subclass of unittest.TestCase that always
> calls 
> > tearDown() for all of our tests at Racemi.
> 
> thanks for your feedback.  py.test will do that as well with 1.2.1 -
> with 
> the addition that triggering "Skipped" exceptions in a setup function
> will 
> not call teardown.

Why not?

Consider:

setUp:
   self.foo = get_foo()
   if not isinstance(self.foo, TestableThing):
       raise TestSkipped()

Why should this /not/ call tearDown ?

-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/20100128/7d9e0bec/attachment.pgp>


More information about the testing-in-python mailing list