[Python-checkins] Fix RuntimeWarning in unittest.mock asyncio example (GH-13449)

Miss Islington (bot) webhook-mailer at python.org
Tue May 21 04:47:24 EDT 2019


https://github.com/python/cpython/commit/e7cb23bf2079087068a08502f96fdf20b317d69c
commit: e7cb23bf2079087068a08502f96fdf20b317d69c
branch: master
author: Xtreak <tir.karthi at gmail.com>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019-05-21T01:47:17-07:00
summary:

Fix RuntimeWarning in unittest.mock asyncio example (GH-13449)



* This PR fixes the `RuntimeWarning` in `inspect.isawaitable(mock())` where `mock()` was not awaited.
* Fix typo in asynctest project.

files:
M Doc/library/unittest.mock.rst
M Lib/unittest/mock.py

diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 21e4709f8160..163da9aecdbb 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -862,7 +862,7 @@ object::
     >>> mock = AsyncMock()
     >>> asyncio.iscoroutinefunction(mock)
     True
-    >>> inspect.isawaitable(mock())
+    >>> inspect.isawaitable(mock())  # doctest: +SKIP
     True
 
   The result of ``mock()`` is an async function which will have the outcome
@@ -888,7 +888,7 @@ object::
     >>> mock = MagicMock(async_func)
     >>> mock
     <MagicMock spec='function' id='...'>
-    >>> mock()
+    >>> mock()  # doctest: +SKIP
     <coroutine object AsyncMockMixin._mock_call at ...>
 
   .. method:: assert_awaited()
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 166c10037698..654462cbf7e7 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -2204,7 +2204,7 @@ class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
     :class:`.Mock` object: the wrapped object may have methods
     defined as async function functions.
 
-    Based on Martin Richard's asyntest project.
+    Based on Martin Richard's asynctest project.
     """
 
 



More information about the Python-checkins mailing list