# Path: doubles/allowance.py
# def build_argument_repr_string(args, kwargs):
#     args = [repr(x) for x in args]
#     kwargs = ['{}={!r}'.format(k, v) for k, v in kwargs.items()]
#     return '({})'.format(', '.join(args + kwargs))
# 
# Path: doubles/exceptions.py
# class UnallowedMethodCallError(AssertionError):
#     """An exception raised when an unallowed method call is made on a double."""
# 
#     pass
# 
# Path: doubles/proxy_property.py
# class ProxyProperty(property):
#     def __init__(self, name, original):
#         """
#         :param str name: name of the doubled property
#         :param property original: the original property
#         """
#         self._name = name
#         self._original = original
# 
#     def __get__(self, obj, objtype=None):
#         if self._name in obj.__dict__:
#             return obj.__dict__[self._name].__get__(obj, objtype)
#         return self._original.__get__(obj, objtype)


import sys
from functools import wraps
from inspect import isbuiltin
from doubles.allowance import build_argument_repr_string
from doubles.exceptions import UnallowedMethodCallError
from doubles.proxy_property import ProxyProperty

        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)

    def _capture_original_method(self):
        """Saves a reference to the original value of the method to be doubled."""

        self._original_method = self._attr.object

    def _hijack_target(self):
        """Replaces the target method on the target object with the proxy method."""

        if self._target.is_class_or_module():
            setattr(self._target.obj, self._method_name, self)
        elif self._attr.kind == 'property':

# Path: doubles/allowance.py
# def build_argument_repr_string(args, kwargs):
#     args = [repr(x) for x in args]
#     kwargs = ['{}={!r}'.format(k, v) for k, v in kwargs.items()]
#     return '({})'.format(', '.join(args + kwargs))
# 
# Path: doubles/exceptions.py
# class UnallowedMethodCallError(AssertionError):
#     """An exception raised when an unallowed method call is made on a double."""
# 
#     pass
# 
# Path: doubles/proxy_property.py
# class ProxyProperty(property):
#     def __init__(self, name, original):
#         """
#         :param str name: name of the doubled property
#         :param property original: the original property
#         """
#         self._name = name
#         self._original = original
# 
#     def __get__(self, obj, objtype=None):
#         if self._name in obj.__dict__:
#             return obj.__dict__[self._name].__get__(obj, objtype)
#         return self._original.__get__(obj, objtype)


# Path: doubles/proxy_method.py
import sys
from functools import wraps
from inspect import isbuiltin
from doubles.allowance import build_argument_repr_string
from doubles.exceptions import UnallowedMethodCallError
from doubles.proxy_property import ProxyProperty


        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)

    def _capture_original_method(self):
        """Saves a reference to the original value of the method to be doubled."""

        self._original_method = self._attr.object

    def _hijack_target(self):
        """Replaces the target method on the target object with the proxy method."""

        if self._target.is_class_or_module():
            setattr(self._target.obj, self._method_name, self)
        elif self._attr.kind == 'property':

            proxy_property = ProxyProperty(