diff options
Diffstat (limited to 'Doc/library/unittest.mock.rst')
| -rw-r--r-- | Doc/library/unittest.mock.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 9bb342773a..04ff8a61da 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -514,6 +514,20 @@ the *new_callable* argument to :func:`patch`. >>> mock.call_count 2 + For :class:`AsyncMock` the :attr:`call_count` is only iterated if the function + has been awaited: + + >>> mock = AsyncMock() + >>> mock() # doctest: +SKIP + <coroutine object AsyncMockMixin._mock_call at ...> + >>> mock.call_count + 0 + >>> async def main(): + ... await mock() + ... + >>> asyncio.run(main()) + >>> mock.call_count + 1 .. attribute:: return_value |
