Julian Berman added the comment: Now that we have contextlib.ExitStack, I think we should consider that here.
I.e., I think ExitStack deserves a method that calls its __enter__ and __exit__, say .enter() and .exit(), and then the idiom for this wouldn't require anything on TestCase, it'd be: class TestStuff(TestCase): def setUp(self): self.stack = ExitStack() self.stack.enter_context(my_context_manager()) self.stack.enter_context(my_context_manager2()) self.stack.enter_context(my_context_manager3()) self.stack.enter() self.addCleanup(self.stack.exit) ---------- nosy: +Julian _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15351> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com