MCPcopy Index your code
hub / github.com/RustPython/RustPython / _execute_mock_call

Method _execute_mock_call

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected