mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
bpo-39915: Ensure await_args_list is updated according to the order in which coroutines were awaited (GH-18924)
Create call objects with awaited arguments instead of using call_args which has only last call value.
This commit is contained in:
parent
fde44ae6d0
commit
e553f204bf
3 changed files with 16 additions and 1 deletions
|
@ -500,6 +500,17 @@ class AsyncArguments(IsolatedAsyncioTestCase):
|
|||
mock.assert_awaited()
|
||||
self.assertTrue(ran)
|
||||
|
||||
async def test_await_args_list_order(self):
|
||||
async_mock = AsyncMock()
|
||||
mock2 = async_mock(2)
|
||||
mock1 = async_mock(1)
|
||||
await mock1
|
||||
await mock2
|
||||
async_mock.assert_has_awaits([call(1), call(2)])
|
||||
self.assertEqual(async_mock.await_args_list, [call(1), call(2)])
|
||||
self.assertEqual(async_mock.call_args_list, [call(2), call(1)])
|
||||
|
||||
|
||||
class AsyncMagicMethods(unittest.TestCase):
|
||||
def test_async_magic_methods_return_async_mocks(self):
|
||||
m_mock = MagicMock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue