Message186172
| Author |
Julian |
| Recipients |
Julian, cbc, chris.jerdonek, eli.bendersky, eric.araujo, michael.foord, r.david.murray |
| Date |
2013年04月07日.01:25:09 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1365297912.53.0.860016542609.issue15351@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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) |
|