[issue41628] All unittest.mock autospec-generated methods are coroutine functions

2020-08-24 Thread Tom Most
New submission from Tom Most : Given a class: class Foo: def bar(self): pass And an autospec'd mock of it: foo_mock = mock.create_autospec(spec=Foo) The result of `asyncio.iscoroutinefunction()` differs: asyncio.iscoroutinefunction(Foo.bar)# -&g

[issue41628] All unittest.mock autospec-generated methods are coroutine functions

2020-08-24 Thread Tom Most
Tom Most added the comment: Note that this can interact poorly with AsyncMock, introduced in Python 3.8, because it causes a mock generated from a mock produces an object with async methods rather than regular ones. In Python 3.7 chaining mocks like this would produce regular methods. (This