[Python-checkins] bpo-37383: Updates docs to reflect AsyncMock call_count after await. (GH-15761)

Miss Islington (bot) webhook-mailer at python.org
Tue Sep 10 03:31:38 EDT 2019


https://github.com/python/cpython/commit/d4391aa5eb4767e19b7b380a836413e7c47f1fb4
commit: d4391aa5eb4767e19b7b380a836413e7c47f1fb4
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019年09月10日T00:31:34-07:00
summary:
bpo-37383: Updates docs to reflect AsyncMock call_count after await. (GH-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().
(cherry picked from commit b9f65f01fd761da7799f36d29b54518399d3458e)
Co-authored-by: Lisa Roach <lisaroach14 at gmail.com>
files:
M Doc/library/unittest.mock.rst
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 304ba532274d..b2547546f3d6 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
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /