PyDocs

Nav

Development Tools

AsyncMock.assert_awaited_with

  • AsyncMock.assert_awaited_with(*args, **kwargs)
Assert that the last await was with the specified arguments.
1 Example
>>> mock = AsyncMock()
>>> async def main(*args, **kwargs):
...     await mock(*args, **kwargs)
...
>>> asyncio.run(main('foo', bar='bar'))
>>> mock.assert_awaited_with('foo', bar='bar')
>>> mock.assert_awaited_with('other')
Traceback (most recent call last):
...
AssertionError: expected await not found.
Expected: mock('other')
Actual: mock('foo', bar='bar')
from the Python docs
See Also
No see-alsos for unittest.mock/AsyncMock.assert_awaited_with
0 Notes
No notes for AsyncMock.assert_awaited_with