asynctest
asynctest copied to clipboard
Wrapping object with asynctest.Mock does not turn async methods into CoroutineMock
Sample interpreter session:
>>> import asynctest
>>> class Foo:
... async def bar():
... pass
...
>>> f = Foo()
>>> m = asynctest.Mock(wraps=f)
>>> type(m.bar)
<class 'asynctest.mock.MagicMock'>
>>> m = asynctest.Mock(wraps=f, spec=f)
>>> type(m.bar)
<class 'asynctest.mock.CoroutineMock'>
I think just using wraps
should turn wrapped object's coroutines into CoroutineMock
s.
Hm, it's more or less related to #31: currently, there is no mechanism to define how CoroutineMock should behave when it's return value is specified by a coroutine function.
When this behavior is defined, it probably makes sense to have the same behavior with wrapped objects.