[TIP] cleanUp for unittest

Victoria G. Laidler laidler at stsci.edu
Fri Apr 3 11:56:02 PDT 2009



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



More information about the testing-in-python mailing list