MCPcopy Create free account
hub / github.com/RustPython/RustPython / _increment_mock_call

Method _increment_mock_call

Lib/unittest/mock.py:1181–1225  ·  view source on GitHub ↗
(self, /, *args, **kwargs)

Source from the content-addressed store, hash-verified

1179 return self._execute_mock_call(*args, **kwargs)
1180
1181 def _increment_mock_call(self, /, *args, **kwargs):
1182 self.called = True
1183 self.call_count += 1
1184
1185 # handle call_args
1186 # needs to be set here so assertions on call arguments pass before
1187 # execution in the case of awaited calls
1188 _call = _Call((args, kwargs), two=True)
1189 self.call_args = _call
1190 self.call_args_list.append(_call)
1191
1192 # initial stuff for method_calls:
1193 do_method_calls = self._mock_parent is not None
1194 method_call_name = self._mock_name
1195
1196 # initial stuff for mock_calls:
1197 mock_call_name = self._mock_new_name
1198 is_a_call = mock_call_name == '()'
1199 self.mock_calls.append(_Call(('', args, kwargs)))
1200
1201 # follow up the chain of mocks:
1202 _new_parent = self._mock_new_parent
1203 while _new_parent is not None:
1204
1205 # handle method_calls:
1206 if do_method_calls:
1207 _new_parent.method_calls.append(_Call((method_call_name, args, kwargs)))
1208 do_method_calls = _new_parent._mock_parent is not None
1209 if do_method_calls:
1210 method_call_name = _new_parent._mock_name + '.' + method_call_name
1211
1212 # handle mock_calls:
1213 this_mock_call = _Call((mock_call_name, args, kwargs))
1214 _new_parent.mock_calls.append(this_mock_call)
1215
1216 if _new_parent._mock_new_name:
1217 if is_a_call:
1218 dot = ''
1219 else:
1220 dot = '.'
1221 is_a_call = _new_parent._mock_new_name == '()'
1222 mock_call_name = _new_parent._mock_new_name + dot + mock_call_name
1223
1224 # follow the parental chain:
1225 _new_parent = _new_parent._mock_new_parent
1226
1227 def _execute_mock_call(self, /, *args, **kwargs):
1228 # separate from _increment_mock_call so that awaited functions are

Callers 2

__call__Method · 0.95
__call__Method · 0.80

Calls 2

_CallClass · 0.85
appendMethod · 0.45

Tested by 1

__call__Method · 0.64