Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:
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 ---------- nosy: +lisroach, mariocj89 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37015> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com