in doubles/proxy_method.py [0:0]
def restore_original_method(self):
"""Replaces the proxy method on the target object with its original value."""
if self._target.is_class_or_module():
setattr(self._target.obj, self._method_name, self._original_method)
if self._method_name == '__new__' and sys.version_info >= (3, 0):
_restore__new__(self._target.obj, self._original_method)
else:
setattr(self._target.obj, self._method_name, self._original_method)
elif self._attr.kind == 'property':
setattr(self._target.obj.__class__, self._method_name, self._original_method)
del self._target.obj.__dict__[double_name(self._method_name)]
elif self._attr.kind == 'attribute':
self._target.obj.__dict__[self._method_name] = self._original_method
else:
# TODO: Could there ever have been a value here that needs to be restored?
del self._target.obj.__dict__[self._method_name]
if self._method_name in ['__call__', '__enter__', '__exit__']:
self._target.restore_attr(self._method_name)