Message352000
Sorry, is there an example of this use case. I went through the issue but have trouble understanding it since there are different suggestions. I guess child mock is always an AsyncMock irrespective of sync/async as I understand. We already had some reports over detecting async while patching to return AsyncMock and also had to document it to the users along with covering different ways of async functions.
from unittest.mock import AsyncMock
class Foo:
def foo(self):
pass
async def bar(self):
pass
m = AsyncMock(Foo)
f = m()
print(m.foo)
print(m.bar)
$ python3.8 /tmp/bar.py
<AsyncMock name='mock.foo' id='4313089744'>
<AsyncMock name='mock.bar' id='4313395696'>
sys:1: RuntimeWarning: coroutine 'AsyncMockMixin._mock_call' was never awaited |
|
Date |
User |
Action |
Args |
2019-09-11 17:41:45 | xtreak | set | recipients:
+ xtreak, cjw296, ezio.melotti, michael.foord, lisroach |
2019-09-11 17:41:45 | xtreak | set | messageid: <1568223705.27.0.765248304995.issue38122@roundup.psfhosted.org> |
2019-09-11 17:41:45 | xtreak | link | issue38122 messages |
2019-09-11 17:41:45 | xtreak | create | |
|