[TIP] cleanUp for unittest
holger at merlinux.eu
Fri Apr 3 10:30:19 PDT 2009
On Fri, Apr 03, 2009 at 18:16 +0100, Michael Foord wrote:
> C. Titus Brown wrote:
> > On Fri, Apr 03, 2009 at 06:08:58PM +0100, Michael Foord wrote:
> > -> There is a feature request for unittest that we add a 'cleanUp' list.
> > ->
> > -> This is a list of functions to call on exit of a test that can be added
> > -> to in setUp or during test execution. The difference between this and
> > -> tearDown is that if anything is in the cleanUp list they will be called
> > -> *even* if setUp fails (which normally means tearDown is skipped).
> > ->
> > -> Is there consensus that adding this to unittest is a good thing? If
> > -> there is then I will just do it...
> > ->
> > -> Should it be done before or after calling tearDown? I don't think it
> > -> matters so long as it is documented.
> > Doesn't matter to me, but I'm wondering... why a list of functions?
> > --titus
> I should have listed the relevant issue: http://bugs.python.org/issue5538
> The idea is that as you allocate resources that need cleaning up, you
> push the corresponding clean up function onto the list. It is what trial
> It sounds like a very simple system to me.
hum, doesn't something like
express well enough what the poster wants to do?
Or am i missing something?
I think that running teardown() only when setup() suceeded
seems nice and simple. Adding more logic to unittest.py for
handling "cleanUps" in addition to "teardDown"'s and explaining
how this relates sounds relatively complicated to me.
just my 2cents,
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
Metaprogramming, Python, Testing: http://tetamap.wordpress.com
Python, PyPy, pytest contracting: http://merlinux.eu
More information about the testing-in-python