gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (GH-94050) (GH-94460)

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>
(cherry picked from commit 4261b6bffc)

Co-authored-by: Mehdi ABAAKOUK <sileht@sileht.net>
This commit is contained in:
Miss Islington (bot) 2022-06-30 11:04:42 -07:00 committed by GitHub
parent 7fe949e5ea
commit 9ebec7d46c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 1 deletions

View file

@ -1653,6 +1653,7 @@ class BaseTaskTests:
self.assertTrue(asyncio.iscoroutinefunction(fn2))
self.assertFalse(asyncio.iscoroutinefunction(mock.Mock()))
self.assertTrue(asyncio.iscoroutinefunction(mock.AsyncMock()))
def test_coroutine_non_gen_function(self):
async def func():