in doubles/target.py [0:0]
def hijack_attr(self, attr_name):
"""Hijack an attribute on the target object.
Updates the underlying class and delegating the call to the instance.
This allows specially-handled attributes like __call__, __enter__,
and __exit__ to be mocked on a per-instance basis.
:param str attr_name: the name of the attribute to hijack
"""
if not self._original_attr(attr_name):
setattr(
self.obj.__class__,
attr_name,
_proxy_class_method_to_instance(
getattr(self.obj.__class__, attr_name, None), attr_name
),
)