[issue11664] Add patch method to unittest.TestCase

Martin Panter report at bugs.python.org
Mon Oct 13 04:31:42 CEST 2014


Martin Panter added the comment:

[padding to avoid UTF-8 error with bug tracker]

See also Issue 22374, where an equivalent of “patch.object” is suggested as an example context manager for the “contextlib” documentation.

If we added a plain function or context manager rather than a new TestCase method, it might avoid the worries about bloating the API. Then it could be a generic thing for any kind of testing, and not coupled with the “unittest” framework.

About cleanup functions more generally, I think they already tie in well with the TestCase.addCleanup() API. Perhaps it could handle general context managers as well though, by inheriting an ExitStack.enter_context() method or providing an ExitStack attribute.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11664>
_______________________________________


More information about the Python-bugs-list mailing list