[TIP] cleanUp for unittest

Marius Gedminas marius at gedmin.as
Fri Apr 3 16:44:10 PDT 2009


On Fri, Apr 03, 2009 at 07:30:19PM +0200, holger krekel wrote:
> hum, doesn't something like 
> 
>     def setUp(self):
>         try:
>             ...
>         finally:
>             self.tearDown()
> 
> express well enough what the poster wants to do?  
> Or am i missing something? 

I think you mean

        def setUp(self):
            try:
                ...
            except:
                self.tearDown()
                raise

It's a lot of boilerplate to write in your every setUp method, and easy
to get wrong.

Marius Gedminas
-- 
Did you hear that the author of _Nitpicking for Dummies_ has just
received it back from the publisher with the 182nd set of editorial
markups?
		-- Bill Snyder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.idyll.org/pipermail/testing-in-python/attachments/20090404/551fd71f/attachment.pgp 


More information about the testing-in-python mailing list