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

Method __new__

Lib/unittest/mock.py:446–462  ·  view source on GitHub ↗
(
            cls, spec=None, wraps=None, name=None, spec_set=None,
            parent=None, _spec_state=None, _new_name='', _new_parent=None,
            _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs
        )

Source from the content-addressed store, hash-verified

444 _lock = RLock()
445
446 def __new__(
447 cls, spec=None, wraps=None, name=None, spec_set=None,
448 parent=None, _spec_state=None, _new_name='', _new_parent=None,
449 _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs
450 ):
451 # every instance has its own class
452 # so we can create magic methods on the
453 # class without stomping on other mocks
454 bases = (cls,)
455 if not issubclass(cls, AsyncMockMixin):
456 # Check if spec is an async object or function
457 spec_arg = spec_set or spec
458 if spec_arg is not None and _is_async_obj(spec_arg):
459 bases = (AsyncMockMixin, cls)
460 new = type(cls.__name__, bases, {'__doc__': cls.__doc__})
461 instance = _safe_super(NonCallableMock, cls).__new__(new)
462 return instance
463
464
465 def __init__(

Callers

nothing calls this directly

Calls 2

_is_async_objFunction · 0.85
__new__Method · 0.45

Tested by

no test coverage detected