Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
python3.35118
99366-patch.dict-can-decorate-async.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 99366-patch.dict-can-decorate-async.patch of Package python3.35118
--- Lib/unittest/mock.py | 20 ++++++++++ Misc/NEWS.d/next/Library/2022-10-08-19-39-27.gh-issue-98086.y---WC.rst | 1 2 files changed, 21 insertions(+) --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -24,6 +24,7 @@ __all__ = ( __version__ = '1.0' +import asyncio import inspect import pprint import sys @@ -1548,6 +1549,12 @@ class _patch_dict(object): def __call__(self, f): if isinstance(f, type): return self.decorate_class(f) + if asyncio.iscoroutinefunction(f): + return self.decorate_async_callable(f) + return self.decorate_callable(f) + + + def decorate_callable(self, f): @wraps(f) def _inner(*args, **kw): self._patch_dict() @@ -1556,6 +1563,19 @@ class _patch_dict(object): finally: self._unpatch_dict() + return _inner + + + def decorate_async_callable(self, f): + @wraps(f) + @asyncio.coroutine + def _inner(*args, **kw): + self._patch_dict() + try: + yield from f(*args, **kw) + finally: + self._unpatch_dict() + return _inner --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-10-08-19-39-27.gh-issue-98086.y---WC.rst @@ -0,0 +1 @@ +Make sure ``patch.dict()`` can be applied on async functions.
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor