[issue15351] Add to unittest.TestCase support for using context managers
Chris Jerdonek
report at bugs.python.org
Mon Jul 16 22:53:26 CEST 2012
Chris Jerdonek <chris.jerdonek at gmail.com> added the comment:
Attached is a patch illustrating the API I suggested for discussion.
To add custom setup and teardown context managers, the user can override the following method:
def executeTest(self):
with self.setUpContext():
self.runTestMethod()
The custom context managers can be placed either before or after the existing setUp/tearDown, or both.
The patch preserves the existing behavior that tearDown() should run only if setUp() was successful, and that doCleanups() should always run. All tests continue to pass with the patch.
----------
keywords: +patch
Added file: http://bugs.python.org/file26405/issue-15351-concept.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15351>
_______________________________________
More information about the Python-bugs-list
mailing list