Gregory P. Smith <g...@krypto.org> added the comment: 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. ---------- nosy: +gregory.p.smith _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5679> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com