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

Function _check_and_set_parent

Lib/unittest/mock.py:393–417  ·  view source on GitHub ↗
(parent, value, name, new_name)

Source from the content-addressed store, hash-verified

391
392
393def _check_and_set_parent(parent, value, name, new_name):
394 value = _extract_mock(value)
395
396 if not _is_instance_mock(value):
397 return False
398 if ((value._mock_name or value._mock_new_name) or
399 (value._mock_parent is not None) or
400 (value._mock_new_parent is not None)):
401 return False
402
403 _parent = parent
404 while _parent is not None:
405 # setting a mock (value) as a child or return value of itself
406 # should not modify the mock
407 if _parent is value:
408 return False
409 _parent = _parent._mock_new_parent
410
411 if new_name:
412 value._mock_new_parent = parent
413 value._mock_new_name = new_name
414 if name:
415 value._mock_parent = parent
416 value._mock_name = name
417 return True
418
419# Internal class to identify if we wrapped an iterator object or not.
420class _MockIter(object):

Callers 2

__set_return_valueMethod · 0.85
__setattr__Method · 0.85

Calls 2

_extract_mockFunction · 0.85
_is_instance_mockFunction · 0.85

Tested by

no test coverage detected