Message85323
I'm used to doing this using a finally clause in the setUp() method (if
I do it at all, I'm not used to setUp failing).
I guess this would be a convenience to avoid the need for this pattern?
I'm not sure we really need a list of cleanup callbacks. Got pointers
to good examples of this in bzr/twisted/zope?
def setUp(self):
try:
do_a_bunch_of_stuff_that_could_fail()
finally:
conditionally_undo_setup()
do_more()
def conditionally_undo_setup(self):
if self.foo:
self.foo.close()
if self.bar:
shutil.rmtree(self.bar)
def tearDown(self):
conditionally_undo_setup()
undo_more()
fwiw, in your self.db.close example, normally i'd also want to remove
and unlink the database as well as just closing it for a unittest.
maybe not the best example. |
|
Date |
User |
Action |
Args |
2009-04-03 20:09:46 | gregory.p.smith | set | recipients:
+ gregory.p.smith, michael.foord |
2009-04-03 20:09:46 | gregory.p.smith | set | messageid: <1238789386.47.0.139212159973.issue5679@psf.upfronthosting.co.za> |
2009-04-03 20:09:45 | gregory.p.smith | link | issue5679 messages |
2009-04-03 20:09:44 | gregory.p.smith | create | |
|