[TIP] cleanUp for unittest

holger krekel holger at merlinux.eu
Sat Apr 4 00:03:28 PDT 2009


On Sat, Apr 04, 2009 at 02:44 +0300, Marius Gedminas wrote:
> 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.

sure, but it can be factored out. 

holger
 
> 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


> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python


-- 
Metaprogramming, Python, Testing: http://tetamap.wordpress.com
Python, PyPy, pytest contracting: http://merlinux.eu 



More information about the testing-in-python mailing list