[TIP] cleanUp for unittest

jason pellerin jpellerin at gmail.com
Fri Apr 3 12:16:07 PDT 2009


On Fri, Apr 3, 2009 at 3:00 PM, Kumar McMillan <kumar.mcmillan at gmail.com> wrote:

> I know Python is all about giving you rope to hang yourself with, but
> I really think a non-list version of cleanUp() would be setting up a
> huge booby trap for the coder.  Since cleanUp() is called
> *unconditionally* after setUp() there are infinite ways to screw that
> up.  However, if cleanUp was a list of callables then there is really
> no way to screw that up.

I can think of one or two. :) It's really the same thing -- something
gets called after every test -- only the way you register that
something is different. One way is simple for simple uses, easy to
extend, and works like everything else in unittest. The other way is
slightly easier for one particular use case, slightly harder for all
the others due to the mental math you have to do to map into the
blessed case, and nothing like the rest of unittest. Or so it seems to
me at any rate.

JP



More information about the testing-in-python mailing list