用法:
assert_awaited_once_with(*args, **kwargs)
断言模拟只等待了一次并使用指定的参数。
>>> mock = AsyncMock() >>> async def main(*args, **kwargs): ... await mock(*args, **kwargs) ... >>> asyncio.run(main('foo', bar='bar')) >>> mock.assert_awaited_once_with('foo', bar='bar') >>> asyncio.run(main('foo', bar='bar')) >>> mock.assert_awaited_once_with('foo', bar='bar') Traceback (most recent call last): ... AssertionError: Expected mock to have been awaited once. Awaited 2 times.
相关用法
- Python unittest.mock.AsyncMock.assert_awaited_once用法及代码示例
- Python unittest.mock.AsyncMock.assert_awaited_with用法及代码示例
- Python unittest.mock.AsyncMock.assert_awaited用法及代码示例
- Python unittest.mock.AsyncMock.assert_any_await用法及代码示例
- Python unittest.mock.AsyncMock.assert_has_awaits用法及代码示例
- 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_awaited_once_with。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。