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

Method __init__

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

Source from the content-addressed store, hash-verified

2286 await_args_list = _delegating_property('await_args_list')
2287
2288 def __init__(self, /, *args, **kwargs):
2289 super().__init__(*args, **kwargs)
2290 # iscoroutinefunction() checks _is_coroutine property to say if an
2291 # object is a coroutine. Without this check it looks to see if it is a
2292 # function/method, which in this case it is not (since it is an
2293 # AsyncMock).
2294 # It is set through __dict__ because when spec_set is True, this
2295 # attribute is likely undefined.
2296 self.__dict__['_is_coroutine'] = asyncio.coroutines._is_coroutine
2297 self.__dict__['_mock_await_count'] = 0
2298 self.__dict__['_mock_await_args'] = None
2299 self.__dict__['_mock_await_args_list'] = _CallList()
2300 if _CODE_SIG:
2301 code_mock = NonCallableMock(spec_set=_CODE_ATTRS)
2302 code_mock.__dict__["_spec_class"] = CodeType
2303 code_mock.__dict__["_spec_signature"] = _CODE_SIG
2304 else:
2305 code_mock = NonCallableMock(spec_set=CodeType)
2306 code_mock.co_flags = (
2307 inspect.CO_COROUTINE
2308 + inspect.CO_VARARGS
2309 + inspect.CO_VARKEYWORDS
2310 )
2311 code_mock.co_argcount = 0
2312 code_mock.co_varnames = ('args', 'kwargs')
2313 code_mock.co_posonlyargcount = 0
2314 code_mock.co_kwonlyargcount = 0
2315 self.__dict__['__code__'] = code_mock
2316 self.__dict__['__name__'] = 'AsyncMock'
2317 self.__dict__['__defaults__'] = tuple()
2318 self.__dict__['__kwdefaults__'] = {}
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

Callers

nothing calls this directly

Calls 4

superClass · 0.85
_CallListClass · 0.85
NonCallableMockClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected