[TIP] cleanUp for unittest
Michael Foord
fuzzyman at voidspace.org.uk
Fri Apr 3 12:02:11 PDT 2009
Victoria G. Laidler wrote:
>
>
> Michael Foord wrote:
>> jason pellerin wrote:
>>
>>> def cleanUp(self):
>>> for func in self._cleanUp:
>>> func()
>>>
>>>
>>
>> So where do you put that - in the test, in tearDown?
>>
>> Should TempIO() fail (for whatever reason), then neither the test nor
>> tearDown would be executed and the cleanup not done. How do you
>> propose to solve that?
>>
>>
> I thought Jason's suggestion was that there may be a cleanUp method,
> rather than list, which would be called after tearDown and no matter
> what.
>
> If cleanUp were to be a list, I'd prefer that it be spelled
> differently, to make a clearer distinction between it and the setUp
> and tearDown methods. Maybe cleanUpList.
>
> Vicki
He was against adding it to built in functionality and suggesting an
alternative way to do it without having it in the standard TestCase (my
reading anyway). In which case the burden is on the developer to call it
themselves and that means in the test or in tearDown - neither of which
get called if the setUp fails for any reason.
Michael
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
More information about the testing-in-python
mailing list