summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorMatthew Kokotovich <mkokotovich@gmail.com>2020-01-25 10:17:47 (GMT)
committerChris Withers <chris@withers.org>2020-01-25 10:17:47 (GMT)
commit62865f4532094017a9b780b704686ca9734bc329 (patch)
treeb0673a2959839526c335b9c6bd37e5bdc0bfd68a /Lib/unittest/mock.py
parentd0d9fa8c5e30aff71b6d5e8b2673396622f33270 (diff)
downloadcpython-62865f4532094017a9b780b704686ca9734bc329.zip
cpython-62865f4532094017a9b780b704686ca9734bc329.tar.gz
cpython-62865f4532094017a9b780b704686ca9734bc329.tar.bz2
bpo-39082: Allow AsyncMock to correctly patch static/class methods (GH-18116)
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 92b596f..047ae7c 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -46,6 +46,8 @@ _safe_super = super
def _is_async_obj(obj):
if _is_instance_mock(obj) and not isinstance(obj, AsyncMock):
return False
+ if hasattr(obj, '__func__'):
+ obj = getattr(obj, '__func__')
return asyncio.iscoroutinefunction(obj) or inspect.isawaitable(obj)