MCPcopy Index your code
hub / github.com/python/cpython / _execute_mock_call

Method _execute_mock_call

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

Source from the content-addressed store, hash-verified

1232 _new_parent = _new_parent._mock_new_parent
1233
1234 def _execute_mock_call(self, /, *args, **kwargs):
1235 # separate from _increment_mock_call so that awaited functions are
1236 # executed separately from their call, also AsyncMock overrides this method
1237
1238 effect = self.side_effect
1239 if effect is not None:
1240 if _is_exception(effect):
1241 raise effect
1242 elif not _callable(effect):
1243 result = next(effect)
1244 if _is_exception(result):
1245 raise result
1246 else:
1247 result = effect(*args, **kwargs)
1248
1249 if result is not DEFAULT:
1250 return result
1251
1252 if self._mock_return_value is not DEFAULT:
1253 return self.return_value
1254
1255 if self._mock_delegate and self._mock_delegate.return_value is not DEFAULT:
1256 return self.return_value
1257
1258 if self._mock_wraps is not None:
1259 return self._mock_wraps(*args, **kwargs)
1260
1261 return self.return_value
1262
1263
1264

Callers 1

_mock_callMethod · 0.95

Calls 2

_is_exceptionFunction · 0.85
_callableFunction · 0.85

Tested by

no test coverage detected