[New-bugs-announce] [issue38857] AsyncMock issue with awaitable return_value/side_effect/wraps
Jason Fried
report at bugs.python.org
Tue Nov 19 18:04:13 EST 2019
New submission from Jason Fried <me at jasonfried.info>:
If you are trying to use AsyncMock to mock a coroutine that returns awaitable objects, AsyncMock awaits on those objects instead of returning them as is.
Example:
mock = AsyncMock(return_value=asyncio.Future())
v = await mock() # blocks on trying to await the future
Expected:
mock = AsyncMock(return_value=asyncio.Future())
v = await mock()
assert isisnstance(v, asyncio.Future)
This problem affects side_effects and wraps.
----------
components: Library (Lib)
messages: 357000
nosy: fried, lisroach
priority: normal
severity: normal
status: open
title: AsyncMock issue with awaitable return_value/side_effect/wraps
versions: Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38857>
_______________________________________
More information about the New-bugs-announce
mailing list