FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-39915: Ensure await_args_list is updated according to the order in which coroutines were awaited by tirkarthi · Pull Request #18924 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Lib/unittest/mock.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ async def _execute_mock_call(self, /, *args, **kwargs):
# This is nearly just like super(), except for special handling
# of coroutines

_call = self.call_args
_call = _Call((args, kwargs), two=True)
self.await_count += 1
self.await_args = _call
self.await_args_list.append(_call)
Expand Down
11 changes: 11 additions & 0 deletions Lib/unittest/test/testmock/testasync.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,17 @@ def inner():
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()
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Ensure :attr:`unittest.mock.AsyncMock.await_args_list` has call objects in
the order of awaited arguments instead of using
:attr:`unittest.mock.Mock.call_args` which has the last value of the call.
Patch by Karthikeyan Singaravelan.

Back | FazBrowse Home | New Git URL