[issue38136] Remove AsyncMock.assert_awaited_*
Lisa Roach
report at bugs.python.org
Thu Sep 12 10:04:34 EDT 2019
Lisa Roach <lisaroach14 at gmail.com> added the comment:
Going to try to recap an in-person conversation:
There are some cases where calls are made separate from when they are awaited, for example:
>>> call = foo()
>>> await call
This would be 1 call and 1 await:
Call List Await List
--------- ----------
[foo] [call]
Calls like:
>>> await foo()
Should also be counted as 1 call and 1 await, there is no difference between this call and the call above (expect for slight differences in when the lists are updated):
Call List Await List
--------- ----------
[foo] [call]
If someone were to do this:
>>>call_1 = foo()
>>>call_2 = foo()
>>> await call_1
>>> await foo(x)
We should see 2 calls added to the call list, then 1 await added to the await list, then 1 call added to the call list and 1 await added to the await list. We would end up with 3 calls and 2 awaits.
Call List Await List
--------- ----------
[foo, foo, foo] [call_1, foo]
And a call without an await:
>>> call = foo()
Call List Await List
--------- ----------
[foo] []
With a setup like this, we would keep the API the same (leaving in the assert_await*). There is some risk that users will incorrectly be using assert_call* when they really want to test awaits, but we can try to make to docs as clear as possible around this.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38136>
_______________________________________
More information about the Python-bugs-list
mailing list