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

Method _execute_mock_call

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

Source from the content-addressed store, hash-verified

2319 self.__dict__['__annotations__'] = None
2320
2321 async def _execute_mock_call(self, /, *args, **kwargs):
2322 # This is nearly just like super(), except for special handling
2323 # of coroutines
2324
2325 _call = _Call((args, kwargs), two=True)
2326 self.await_count += 1
2327 self.await_args = _call
2328 self.await_args_list.append(_call)
2329
2330 effect = self.side_effect
2331 if effect is not None:
2332 if _is_exception(effect):
2333 raise effect
2334 elif not _callable(effect):
2335 try:
2336 result = next(effect)
2337 except StopIteration:
2338 # It is impossible to propagate a StopIteration
2339 # through coroutines because of PEP 479
2340 raise StopAsyncIteration
2341 if _is_exception(result):
2342 raise result
2343 elif iscoroutinefunction(effect):
2344 result = await effect(*args, **kwargs)
2345 else:
2346 result = effect(*args, **kwargs)
2347
2348 if result is not DEFAULT:
2349 return result
2350
2351 if self._mock_return_value is not DEFAULT:
2352 return self.return_value
2353
2354 if self._mock_wraps is not None:
2355 if iscoroutinefunction(self._mock_wraps):
2356 return await self._mock_wraps(*args, **kwargs)
2357 return self._mock_wraps(*args, **kwargs)
2358
2359 return self.return_value
2360
2361 def assert_awaited(self):
2362 """

Callers

nothing calls this directly

Calls 5

iscoroutinefunctionFunction · 0.90
_CallClass · 0.85
_is_exceptionFunction · 0.85
_callableFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected