[issue39915] AsyncMock doesn't work with asyncio.gather

2020-03-09 Thread Mads Sejersen


New submission from Mads Sejersen :

When calling asyncio.gather the await_args_list is not correct. In the attached 
minimal example it contains only the latest call and not each of the three 
actual calls.

Expected output:
[call(0), call(1), call(2)]
[call(1), call(2), call(3)]  # or any permutation hereof

Actual output:
[call(0), call(1), call(2)]
[call(3), call(3), call(3)]

--
components: asyncio
files: fail.py
messages: 363748
nosy: Mads Sejersen, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: AsyncMock doesn't work with asyncio.gather
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file48963/fail.py

___
Python tracker 
<https://bugs.python.org/issue39915>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39915] AsyncMock doesn't work with asyncio.gather

2020-03-10 Thread Mads Sejersen


Mads Sejersen  added the comment:

It can actually be boiled down to an even more minimal example. It looks like 
the problem is that the function call is stored for later when called, then 
overwritten by other subsequent calls. Then, once awaited, the latest 
registered call is added to the await_args_list instead of the call that 
actually happened.

```
import asyncio
from unittest.mock import AsyncMock


async def main():
foo = AsyncMock()

foo1 = foo(1)
foo2 = foo(2)
await foo1
await foo2
print(foo.await_args_list)


asyncio.run(main())
```

--

___
Python tracker 
<https://bugs.python.org/issue39915>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com