[issue22374] Replace contextmanager example and improve explanation

Martin Panter report at bugs.python.org
Wed Sep 10 09:21:53 CEST 2014


Martin Panter added the comment:

You should probably use try / finally in your context manager to always restore the attribute. Having said that, I recently wrote a similar context manager, and then later discovered there is already “unittest.mock.patch” and/or “unittest.mock.patch.object” via Issue 11664, which apparently can do this job.

----------
nosy: +vadmium

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


More information about the Python-bugs-list mailing list