Return value of CoroutineMock is not an instance of abc.Coroutine
An awaitable should always return a coroutine and thus should inherit from this class.
Thanks for the report.
Do you mean that someting like isinstance(my_coro_mock(), collections.abc.Coroutine) should be True?
It seems that Python itself doesn't enforce this with decorated functions:
import collections.abc, asyncio
@asyncio.coroutine
def foo():
pass
isinstance(foo, collections.abc.Coroutine) # False
isinstance(foo(), collections.abc.Coroutine) # False
I mean, it makes sense for the return value of a CoroutineMock to inherit from abc.Coroutine, but it's not (yet) the case because @asyncio.coroutine doesn't make it so.
With the deprecation of old-style coroutines, we should have an opportunity to fix this.
The doc say:
Note In CPython, generator-based coroutines (generators decorated with types.coroutine() or asyncio.coroutine()) are awaitables, even though they do not have an await() method. Using isinstance(gencoro, Coroutine) for them will return False. Use inspect.isawaitable() to detect them.