def _get_doubles_target()

in doubles/instance_double.py [0:0]


def _get_doubles_target(module, class_name, path):
    """Validate and return the class to be doubled.

    :param module module: The module that contains the class that will be doubled.
    :param str class_name: The name of the class that will be doubled.
    :param str path: The full path to the class that will be doubled.
    :return: The class that will be doubled.
    :rtype: type
    :raise: ``VerifyingDoubleImportError`` if the target object doesn't exist or isn't a class.
    """

    try:
        doubles_target = getattr(module, class_name)
        if isinstance(doubles_target, ObjectDouble):
            return doubles_target._doubles_target

        if not isclass(doubles_target):
            raise VerifyingDoubleImportError(
                'Path does not point to a class: {}.'.format(path)
            )

        return doubles_target
    except AttributeError:
        raise VerifyingDoubleImportError(
            'No object at path: {}.'.format(path)
        )