# Path: doubles/exceptions.py
# class VerifyingDoubleArgumentError(AssertionError):
#     """
#     An exception raised when attempting to double a method with arguments that do not match the
#     signature of the real method.
#     """
# 
#     pass
# 
# class VerifyingBuiltinDoubleArgumentError(VerifyingDoubleArgumentError):
#     """
#     An exception raised when attempting to validate arguments of a builtin.
#     """
# 
#     pass
# 
# class VerifyingDoubleError(AssertionError):
#     """
#     An exception raised when attempting to double a method that does not exist on the real object.
#     """
# 
#     def __init__(self, method_name, doubled_obj):
#         """
#         :param str method_name: The name of the method to double.
#         :param object doubled_obj: The real object being doubled.
#         """
# 
#         self._method_name = method_name
#         self._doubled_obj = doubled_obj
#         self.args = (method_name, doubled_obj)
#         self.message = "Cannot double method '{}' of '{}'."
# 
#     def no_matching_method(self):
#         self.message = "Cannot double method '{}' because {} does not implement it."
# 
#         return self
# 
#     def not_callable(self):
#         self.message = "Cannot double method '{}' because it is not a callable attribute on {}."
# 
#         return self
# 
#     def requires_instance(self):
#         self.message = "Cannot double method '{}' because it is not callable directly on {}."
# 
#         return self
# 
#     def __str__(self):
#         return self.message.format(self._method_name, self._doubled_obj)


import sys
from inspect import isbuiltin, getcallargs, isfunction, ismethod
from doubles.exceptions import (
    VerifyingDoubleArgumentError,
    VerifyingBuiltinDoubleArgumentError,
    VerifyingDoubleError,
)

    :param class target: The class to verify against.
    :param tuple args:  Positional arguments.
    :params dict kwargs: Keyword arguments.
    """
    if not _is_python_function(target.doubled_obj.__init__):
        class_ = target.doubled_obj
        if args and not kwargs and issubclass(class_, ACCEPTS_ARGS):
            return True
        elif kwargs and not args and issubclass(class_, ACCEPTS_KWARGS):
            return True
        elif args or kwargs:
            given_args_count = 1 + len(args) + len(kwargs)
            raise VerifyingDoubleArgumentError(
                '__init__() takes exactly 1 arguments ({} given)'.format(
                    given_args_count,
                )
            )
        return

    return _verify_arguments(
        target.doubled_obj.__init__,
        '__init__',
        ['self'] + list(args),
        kwargs,
    )


def _raise_doubles_error_from_index_error(method_name):
    # Work Around for http://bugs.python.org/issue20817

# Path: doubles/exceptions.py
# class VerifyingDoubleArgumentError(AssertionError):
#     """
#     An exception raised when attempting to double a method with arguments that do not match the
#     signature of the real method.
#     """
# 
#     pass
# 
# class VerifyingBuiltinDoubleArgumentError(VerifyingDoubleArgumentError):
#     """
#     An exception raised when attempting to validate arguments of a builtin.
#     """
# 
#     pass
# 
# class VerifyingDoubleError(AssertionError):
#     """
#     An exception raised when attempting to double a method that does not exist on the real object.
#     """
# 
#     def __init__(self, method_name, doubled_obj):
#         """
#         :param str method_name: The name of the method to double.
#         :param object doubled_obj: The real object being doubled.
#         """
# 
#         self._method_name = method_name
#         self._doubled_obj = doubled_obj
#         self.args = (method_name, doubled_obj)
#         self.message = "Cannot double method '{}' of '{}'."
# 
#     def no_matching_method(self):
#         self.message = "Cannot double method '{}' because {} does not implement it."
# 
#         return self
# 
#     def not_callable(self):
#         self.message = "Cannot double method '{}' because it is not a callable attribute on {}."
# 
#         return self
# 
#     def requires_instance(self):
#         self.message = "Cannot double method '{}' because it is not callable directly on {}."
# 
#         return self
# 
#     def __str__(self):
#         return self.message.format(self._method_name, self._doubled_obj)


# Path: doubles/verification.py
import sys
from inspect import isbuiltin, getcallargs, isfunction, ismethod
from doubles.exceptions import (
    VerifyingDoubleArgumentError,
    VerifyingBuiltinDoubleArgumentError,
    VerifyingDoubleError,
)


    :param class target: The class to verify against.
    :param tuple args:  Positional arguments.
    :params dict kwargs: Keyword arguments.
    """
    if not _is_python_function(target.doubled_obj.__init__):
        class_ = target.doubled_obj
        if args and not kwargs and issubclass(class_, ACCEPTS_ARGS):
            return True
        elif kwargs and not args and issubclass(class_, ACCEPTS_KWARGS):
            return True
        elif args or kwargs:
            given_args_count = 1 + len(args) + len(kwargs)
            raise VerifyingDoubleArgumentError(
                '__init__() takes exactly 1 arguments ({} given)'.format(
                    given_args_count,
                )
            )
        return

    return _verify_arguments(
        target.doubled_obj.__init__,
        '__init__',
        ['self'] + list(args),
        kwargs,
    )


def _raise_doubles_error_from_index_error(method_name):
    # Work Around for http://bugs.python.org/issue20817

    raise VerifyingDoubleArgumentError(