summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLisa Roach <lisaroach14@gmail.com>2019-09-09 16:54:13 (GMT)
committerGitHub <noreply@github.com>2019-09-09 16:54:13 (GMT)
commitb9f65f01fd761da7799f36d29b54518399d3458e (patch)
tree4dc1722fe081b6bb8b43e9ebbcc48616758cfd85
parentd14e39c8d9a9b525c7dcd83b2a260e2707fa85c1 (diff)
downloadcpython-b9f65f01fd761da7799f36d29b54518399d3458e.zip
cpython-b9f65f01fd761da7799f36d29b54518399d3458e.tar.gz
cpython-b9f65f01fd761da7799f36d29b54518399d3458e.tar.bz2
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().
-rw-r--r--Doc/library/unittest.mock.rst14
1 files changed, 14 insertions, 0 deletions
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
+ <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