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
You can set the return_value
of an async method like so:
mock = unittest.mock.MagicMock()
mock.your_async_method.return_value = task_from_result(your_return_value)
async def task_from_result(result):
return result
The caller will have to do await your_async_method(..)
just like as if the method wasn't mocked.