Ejemplo n.º 1
0
    def from_args(cls, args, arg_prefix):
        """Create a :class:`~.ParallelTestRunner` from command-line arguments.

        """
        initializer_spec = args.process_init
        if initializer_spec is None:
            initializer = None
        else:
            module_name, initializer_name = initializer_spec.rsplit('.', 1)
            init_module = get_module_by_name(module_name)
            initializer = getattr(init_module, initializer_name)
        return cls(process_count=args.processes, initializer=initializer,
                   maxtasksperchild=args.process_max_tasks)
Ejemplo n.º 2
0
    def from_args(cls, args, arg_prefix):
        """Create a :class:`~.ParallelTestRunner` from command-line arguments.

        """
        initializer_spec = args.process_init
        if initializer_spec is None:
            initializer = None
        else:
            module_name, initializer_name = initializer_spec.rsplit('.', 1)
            init_module = get_module_by_name(module_name)
            initializer = getattr(init_module, initializer_name)
        return cls(process_count=args.processes,
                   initializer=initializer,
                   maxtasksperchild=args.process_max_tasks)
Ejemplo n.º 3
0
    def _load_from_file(self, filepath, top_level_directory):
        module_name = get_module_name(top_level_directory, filepath)
        logger.debug('Loading tests from %r', module_name)
        try:
            module = get_module_by_name(module_name)
        except Exception:
            test = _create_import_error_test(module_name)
        else:
            # No exceptions on module import
            # Load tests
            return self._loader.load_module(module)

        # Create the test suite containing handled exception on import
        return self._loader.create_suite((test,))
Ejemplo n.º 4
0
    def _load_from_file(self, filepath, top_level_directory):
        module_name = get_module_name(top_level_directory, filepath)
        logger.debug("Loading tests from %r", module_name)
        try:
            module = get_module_by_name(module_name)
        except Exception:
            test = _create_import_error_test(module_name)
        else:
            # No exceptions on module import
            # Load tests
            return self._loader.load_module(module)

        # Create the test suite containing handled exception on import
        return self._loader.create_suite((test,))
Ejemplo n.º 5
0
def find_module_by_name(full_name):
    module_name = full_name
    module_attributes = []
    while True:
        try:
            module = get_module_by_name(module_name)
        except ImportError:
            if '.' in module_name:
                module_name, attribute = module_name.rsplit('.', 1)
                module_attributes.append(attribute)
            else:
                raise
        else:
            break
    return module, list(reversed(module_attributes))
Ejemplo n.º 6
0
def find_module_by_name(full_name):
    module_name = full_name
    module_attributes = []
    while True:
        try:
            module = get_module_by_name(module_name)
        except ImportError:
            if "." in module_name:
                module_name, attribute = module_name.rsplit(".", 1)
                module_attributes.append(attribute)
            else:
                raise
        else:
            break
    return module, list(reversed(module_attributes))