mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-38136: Updates await_count and call_count to be different things (GH-16192)
This commit is contained in:
parent
6f53d34fb0
commit
ef04851775
5 changed files with 208 additions and 43 deletions
|
@ -1076,14 +1076,20 @@ class CallableMixin(Base):
|
|||
# can't use self in-case a function / method we are mocking uses self
|
||||
# in the signature
|
||||
self._mock_check_sig(*args, **kwargs)
|
||||
self._increment_mock_call(*args, **kwargs)
|
||||
return self._mock_call(*args, **kwargs)
|
||||
|
||||
|
||||
def _mock_call(self, /, *args, **kwargs):
|
||||
return self._execute_mock_call(*args, **kwargs)
|
||||
|
||||
def _increment_mock_call(self, /, *args, **kwargs):
|
||||
self.called = True
|
||||
self.call_count += 1
|
||||
|
||||
# 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)
|
||||
|
@ -1123,6 +1129,10 @@ class CallableMixin(Base):
|
|||
# follow the parental chain:
|
||||
_new_parent = _new_parent._mock_new_parent
|
||||
|
||||
def _execute_mock_call(self, /, *args, **kwargs):
|
||||
# seperate from _increment_mock_call so that awaited functions are
|
||||
# executed seperately from their call
|
||||
|
||||
effect = self.side_effect
|
||||
if effect is not None:
|
||||
if _is_exception(effect):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue