From b9f65f01fd761da7799f36d29b54518399d3458e Mon Sep 17 00:00:00 2001 From: Lisa Roach Date: Mon, 9 Sep 2019 17:54:13 +0100 Subject: bpo-37383: Updates docs to reflect AsyncMock call_count after await. (#15761) * bpo-351428: Updates documentation to reflect AsyncMock call_count after await. * Adds skip and fixes warning. * Removes extra >>>. * Adds ... in front of await mock(). --- Doc/library/unittest.mock.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 9bb3427..04ff8a6 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 -- cgit v0.12