Here are the examples of the python api unittest.mock._is_instance_mock taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Source : mock.py
with Apache License 2.0
from liyinchigithub
with Apache License 2.0
from liyinchigithub
def __setattr__(self, name, value):
_mock_methods = getattr(self, '_mock_methods', None)
if _mock_methods is None or name in _mock_methods:
if name in _async_magics:
if not unittest.mock._is_instance_mock(value):
setattr(type(self), name,
unittest.mock._get_method(name, value))
original = value
def value(*args, **kwargs):
return original(self, *args, **kwargs)
else:
unittest.mock._check_and_set_parent(self, value, None, name)
setattr(type(self), name, value)
self._mock_children[name] = value
return object.__setattr__(self, name, value)
unittest.mock._safe_super(AsyncMagicMixin, self).__setattr__(name, value)
# Notes about unittest.mock:
# - MagicMock > Mock > NonCallableMock (where ">" means inherits from)
# - when a mock instance is created, a new class (type) is created
# dynamically,
# - we *must* use magic or object's internals when we want to add our own
# properties, and often override __getattr__/__setattr__ which are used
# in unittest.mock.NonCallableMock.
class NonCallableMock(unittest.mock.NonCallableMock,