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 asvetlov, lisroach, mariocj89, xtreak
Date 2019-05-22.19:16:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558552588.71.0.312582942802.issue37015@roundup.psfhosted.org>
In-reply-to
Content
I guess cause is at [0] . When there is no new value specified and with spec being None if mock.patch is used on an async object (original = _accept_connection2). Here original is an async object then AsyncMock is returned. 

Changing this causes test failures where patching AsyncClass.async_method now expects an AsyncMock but as per older behavior it returns MagicMock. I think it's a behavior that needs to be discussed as it differs from 3.7 and not sure if AsyncMock would always be awaited as seen in test_accept_connection_multiple.

[0] https://github.com/python/cpython/blob/b121f63155d8e3c7c42ab6122e36eaf7f5e9f7f5/Lib/unittest/mock.py#L1313

if spec is None and _is_async_obj(original):
    Klass = AsyncMock
else:
    Klass = MagicMock
History
Date User Action Args
2019-05-22 19:16:28xtreaksetrecipients: + xtreak, asvetlov, lisroach, mariocj89
2019-05-22 19:16:28xtreaksetmessageid: <1558552588.71.0.312582942802.issue37015@roundup.psfhosted.org>
2019-05-22 19:16:28xtreaklinkissue37015 messages
2019-05-22 19:16:28xtreakcreate