Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Lib/unittest/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,10 +1184,16 @@ def _increment_mock_call(self, /, *args, **kwargs):
# handle call_args
# needs to be set here so assertions on call arguments pass before
# execution in the case of awaited calls
_call = _Call((args, kwargs), two=True)
self.call_args = _call
self.call_args_list.append(_call)
self.call_count = len(self.call_args_list)
with NonCallableMock._lock:
# Lock is used here so that call_args_list and call_count are
# set atomically otherwise it is possible that by the time call_count
# is set another thread may have appended to call_args_list.
# The rest of this function relies on list.append being atomic and
# skips locking.
_call = _Call((args, kwargs), two=True)
self.call_args = _call
self.call_args_list.append(_call)
self.call_count = len(self.call_args_list)

# initial stuff for method_calls:
do_method_calls = self._mock_parent is not None
Expand Down
Loading