diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 9bb342773a9..04ff8a61da3 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 + + >>> mock.call_count + 0 + >>> async def main(): + ... await mock() + ... + >>> asyncio.run(main()) + >>> mock.call_count + 1 .. attribute:: return_value