当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python unittest.mock.AsyncMock.assert_awaited_once用法及代码示例


用法:

assert_awaited_once()

断言模拟只等待了一次。

>>> mock = AsyncMock()
>>> async def main():
...     await mock()
...
>>> asyncio.run(main())
>>> mock.assert_awaited_once()
>>> asyncio.run(main())
>>> mock.method.assert_awaited_once()
Traceback (most recent call last):
...
AssertionError: Expected mock to have been awaited once. Awaited 2 times.

相关用法


注:本文由纯净天空筛选整理自python.org大神的英文原创作品 unittest.mock.AsyncMock.assert_awaited_once。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。