How do I mock async call from one native coroutine to other one using unittest.mock.patch
?
I currently have quite an awkward solution:
c
Everyone's missing what's probably the simplest and clearest solution:
@patch('some.path')
def test(self, mock):
f = asyncio.Future()
f.set_result('whatever result you want')
process_smtp_message.return_value = f
mock.assert_called_with(1, 2, 3)
remember a coroutine can be thought of as just a function which is guaranteed to return a future which can, in turn be awaited.