Browse Source

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.
pull/13461/head
Xtreak 7 years ago
committed by Miss Islington (bot)
parent
commit
e7cb23bf20
  1. 4
      Doc/library/unittest.mock.rst
  2. 2
      Lib/unittest/mock.py

4
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()

2
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.
"""

Loading…
Cancel
Save