用法:
assert_has_awaits(calls, any_order=False)
斷言已通過指定的調用等待模擬。檢查
await_args_list
列表是否等待。如果
any_order
為假,則等待必須是順序的。在指定的等待之前或之後可能會有額外的調用。如果
any_order
為真,則等待可以按任何順序排列,但它們必須全部出現在await_args_list
中。>>> mock = AsyncMock() >>> async def main(*args, **kwargs): ... await mock(*args, **kwargs) ... >>> calls = [call("foo"), call("bar")] >>> mock.assert_has_awaits(calls) Traceback (most recent call last): ... AssertionError: Awaits not found. Expected: [call('foo'), call('bar')] Actual: [] >>> asyncio.run(main('foo')) >>> asyncio.run(main('bar')) >>> mock.assert_has_awaits(calls)
相關用法
- Python unittest.mock.AsyncMock.assert_awaited_once_with用法及代碼示例
- Python unittest.mock.AsyncMock.assert_any_await用法及代碼示例
- Python unittest.mock.AsyncMock.assert_awaited_with用法及代碼示例
- Python unittest.mock.AsyncMock.assert_awaited_once用法及代碼示例
- Python unittest.mock.AsyncMock.assert_awaited用法及代碼示例
- Python unittest.mock.AsyncMock.await_args_list用法及代碼示例
- Python unittest.mock.AsyncMock.await_count用法及代碼示例
- Python unittest.mock.AsyncMock.await_args用法及代碼示例
- Python unittest.mock.AsyncMock用法及代碼示例
- Python unittest.mock.Mock.reset_mock用法及代碼示例
- Python unittest.mock.Mock.__class__用法及代碼示例
- Python unittest.mock.Mock.call_args用法及代碼示例
- Python unittest.mock.call用法及代碼示例
- Python unittest.mock.Mock.method_calls用法及代碼示例
- Python unittest.mock.Mock.call_args_list用法及代碼示例
- Python unittest.mock.Mock.assert_called用法及代碼示例
- Python unittest.mock.Mock.assert_not_called用法及代碼示例
- Python unittest.mock.Mock.mock_calls用法及代碼示例
- Python unittest.mock.Mock.assert_has_calls用法及代碼示例
- Python unittest.mock.Mock.configure_mock用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 unittest.mock.AsyncMock.assert_has_awaits。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。