summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorLisa Roach <lisaroach14@gmail.com>2019-09-27 22:44:34 (GMT)
committerGitHub <noreply@github.com>2019-09-27 22:44:34 (GMT)
commit52bdd414ed9da7c62c312c542803753986a0040a (patch)
tree249181d65faf57fb5ac63384526492cd63c48cbb /Lib/unittest/mock.py
parent6447b9f9bd27e1f6b04cef674dd3a7ab27bf4f28 (diff)
downloadcpython-52bdd414ed9da7c62c312c542803753986a0040a.zip
cpython-52bdd414ed9da7c62c312c542803753986a0040a.tar.gz
cpython-52bdd414ed9da7c62c312c542803753986a0040a.tar.bz2
[3.8] bpo-38136: Updates await_count and call_count to be different things (GH-16192) (GH-16431)
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 30f4663..5ea5624 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1070,14 +1070,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)
@@ -1117,6 +1123,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):