mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +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
|
@ -2175,6 +2175,10 @@ class AsyncMockMixin(Base):
|
|||
code_mock = NonCallableMock(spec_set=CodeType)
|
||||
code_mock.co_flags = inspect.CO_COROUTINE
|
||||
self.__dict__['__code__'] = code_mock
|
||||
self.__dict__['__name__'] = 'AsyncMock'
|
||||
self.__dict__['__defaults__'] = tuple()
|
||||
self.__dict__['__kwdefaults__'] = {}
|
||||
self.__dict__['__annotations__'] = None
|
||||
|
||||
async def _execute_mock_call(self, /, *args, **kwargs):
|
||||
# This is nearly just like super(), except for special handling
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue