[issue5679] cleanUp stack for unittest

Michael Foord report at bugs.python.org
Sun Apr 5 22:36:00 CEST 2009


Michael Foord <michael at voidspace.org.uk> added the comment:

I'm in favour of running clean ups afterwards on the basis that it makes
things possible that would otherwise not be possible.

> If your cleanup relies on something which has been set up during setUp
> and will be dropped during tearDown (a database connection, a temp dir,
> an ssh session, whatever), then the cleanup must be run before the
> teardown.

But this is a function of whichever way we do it - and so not an
argument for one way or the other. Conversely if you write a tearDown
that relies on resources existing that will later be removed by a clean
up then clean ups must be run afterwards.

> The point is that sequence 2 can already be emulated using careful
> "try...finally" in tearDown, while sequence 1 cannot. That is, sequence
> 1 *needs* the addCleanup, while for sequence 2 it is a mere additional
> convenience.

Which is an argument in favour of running clean ups afterwards.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5679>
_______________________________________


More information about the Python-bugs-list mailing list