[TIP] cleanUp for unittest

Victoria G. Laidler laidler at stsci.edu
Fri Apr 3 10:53:09 PDT 2009

Kumar's example code:
> def setUp(self):
>    self.db = ScratchDb()
>    self.db.setup()
>    self.cleanUp.append(lambda: self.db.teardown())
>    self.tmp = TempIO()
>    self.cleanUp.append(lambda: self.tmp.destroy())
This looks clean to me except for the lambda, which I don't understand - 
and I'm dithering on whether I think it ought to be a list, as proposed, 
or something else.

My usual case for cleanup behavior is file deletion, with different 
files to be deleted depending on how far I got. Would this work?



More information about the testing-in-python mailing list