mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (#94050)
The inspect version was not working with unittest.mock.AsyncMock. The fix introduces special-casing of AsyncMock in `inspect.iscoroutinefunction` equivalent to the one performed in `asyncio.iscoroutinefunction`. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
639e35108b
commit
4261b6bffc
5 changed files with 23 additions and 1 deletions
|
@ -395,7 +395,7 @@ def _has_code_flag(f, flag):
|
|||
while ismethod(f):
|
||||
f = f.__func__
|
||||
f = functools._unwrap_partial(f)
|
||||
if not isfunction(f):
|
||||
if not (isfunction(f) or _signature_is_functionlike(f)):
|
||||
return False
|
||||
return bool(f.__code__.co_flags & flag)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue