from unittest.mock import AsyncMock async def async_func(a, b): return a + b mock_async_func = AsyncMock() await mock_async_func(2, 3) mock_async_func.assert_called_with(2, 3)
from unittest.mock import AsyncMock class MyClass: async def async_method(self, a, b): return a * b mock_obj = MyClass() mock_obj.async_method = AsyncMock() await mock_obj.async_method(3, 4) mock_obj.async_method.assert_called_with(3, 4)Package/Library: unittest.mock is a part of the Python standard library.