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

Function _setup_async_mock

Lib/unittest/mock.py:282–306  ·  view source on GitHub ↗
(mock)

Source from the content-addressed store, hash-verified

280
281
282def _setup_async_mock(mock):
283 mock._is_coroutine = asyncio.coroutines._is_coroutine
284 mock.await_count = 0
285 mock.await_args = None
286 mock.await_args_list = _CallList()
287
288 # Mock is not configured yet so the attributes are set
289 # to a function and then the corresponding mock helper function
290 # is called when the helper is accessed similar to _setup_func.
291 def wrapper(attr, /, *args, **kwargs):
292 return getattr(mock.mock, attr)(*args, **kwargs)
293
294 for attribute in ('assert_awaited',
295 'assert_awaited_once',
296 'assert_awaited_with',
297 'assert_awaited_once_with',
298 'assert_any_await',
299 'assert_has_awaits',
300 'assert_not_awaited'):
301
302 # setattr(mock, attribute, wrapper) causes late binding
303 # hence attribute will always be the last value in the loop
304 # Use partial(wrapper, attribute) to ensure the attribute is bound
305 # correctly.
306 setattr(mock, attribute, partial(wrapper, attribute))
307
308
309def _is_magic(name):

Callers 1

_set_async_signatureFunction · 0.85

Calls 3

partialClass · 0.90
_CallListClass · 0.85
setattrFunction · 0.85

Tested by

no test coverage detected