This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients cjw296, ezio.melotti, lisroach, michael.foord, xtreak
Date 2019-09-11.17:41:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568223705.27.0.765248304995.issue38122@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-09-11 17:41:45xtreaksetrecipients: + xtreak, cjw296, ezio.melotti, michael.foord, lisroach
2019-09-11 17:41:45xtreaksetmessageid: <1568223705.27.0.765248304995.issue38122@roundup.psfhosted.org>
2019-09-11 17:41:45xtreaklinkissue38122 messages
2019-09-11 17:41:45xtreakcreate