summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorLisa Roach <lisaroach14@gmail.com>2019-09-10 11:18:40 (GMT)
committerGitHub <noreply@github.com>2019-09-10 11:18:40 (GMT)
commitf1a297acb60b88917712450ebd3cfa707e6efd6b (patch)
treec1307ca321b2aae7abc43f714a7310a38331c4a6 /Lib/unittest/mock.py
parent5a7d2e11aaea2dd32878dc5c6b1aae8caf56cb44 (diff)
downloadcpython-f1a297acb60b88917712450ebd3cfa707e6efd6b.zip
cpython-f1a297acb60b88917712450ebd3cfa707e6efd6b.tar.gz
cpython-f1a297acb60b88917712450ebd3cfa707e6efd6b.tar.bz2
bpo-37251: Removes __code__ check from _is_async_obj. (GH-15830)
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index c26b367..50e4959 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -46,10 +46,9 @@ FILTER_DIR = True
_safe_super = super
def _is_async_obj(obj):
- if getattr(obj, '__code__', None):
- return asyncio.iscoroutinefunction(obj) or inspect.isawaitable(obj)
- else:
+ if _is_instance_mock(obj) and not isinstance(obj, AsyncMock):
return False
+ return asyncio.iscoroutinefunction(obj) or inspect.isawaitable(obj)
def _is_async_func(func):