Skip to content

Commit e7cb23b

Browse files
tirkarthimiss-islington
authored andcommitted
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.
1 parent d0ebf13 commit e7cb23b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Doc/library/unittest.mock.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ object::
862862
>>> mock = AsyncMock()
863863
>>> asyncio.iscoroutinefunction(mock)
864864
True
865-
>>> inspect.isawaitable(mock())
865+
>>> inspect.isawaitable(mock()) # doctest: +SKIP
866866
True
867867

868868
The result of ``mock()`` is an async function which will have the outcome
@@ -888,7 +888,7 @@ object::
888888
>>> mock = MagicMock(async_func)
889889
>>> mock
890890
<MagicMock spec='function' id='...'>
891-
>>> mock()
891+
>>> mock() # doctest: +SKIP
892892
<coroutine object AsyncMockMixin._mock_call at ...>
893893

894894
.. method:: assert_awaited()

Lib/unittest/mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
22042204
:class:`.Mock` object: the wrapped object may have methods
22052205
defined as async function functions.
22062206
2207-
Based on Martin Richard's asyntest project.
2207+
Based on Martin Richard's asynctest project.
22082208
"""
22092209

22102210

0 commit comments

Comments
 (0)