Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Lib/unittest/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3121,6 +3121,10 @@ def _mock_call(self, *args, **kwargs):

return ret_value

def _increment_mock_call(self, /, *args, **kwargs):
with self._mock_calls_events_lock:
super()._increment_mock_call(*args, **kwargs)

def wait_until_called(self, *, timeout=_timeout_unset):
"""Wait until the mock object is called.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix race condition in :class:`unittest.mock.ThreadingMock` where
concurrent calls could lose increments to ``call_count`` and other
attributes due to a missing lock in ``_increment_mock_call``.
Loading