##### SUMMARY

Move the remaining files needed by `ansible-test` into the `test/lib/ansible_test/` directory. This is required to implement: https://github.com/ansible/ansible/issues/59884

##### ISSUE TYPE

Feature Idea

##### COMPONENT NAME

ansible-test

"""Returns true if candidate_path is path or a subdirectory of path."""
    if not path.endswith(os.sep):
        path += os.sep
    if not candidate_path.endswith(os.sep):
        candidate_path += os.sep
    return candidate_path.startswith(path)
def paths_to_dirs(paths):  
    """Returns a list of directories extracted from the given list of paths."""
    dir_names = set()
    for path in paths:
        while True:
            path = os.path.dirname(path)
            if not path or path == os.path.sep:
                break
            dir_names.add(path + os.path.sep)
    return sorted(dir_names)
def import_plugins(directory, root=None):  
    """
    Import plugins from the given directory relative to the given root.
    If the root is not provided, the 'lib' directory for the test runner will be used.
    """
    if root is None:
        root = os.path.dirname(__file__)
    path = os.path.join(root, directory)
    package = __name__.rsplit('.', 1)[0]
    prefix = '%s.%s.' % (package, directory.replace(os.sep, '.'))
    for (_module_loader, name, _ispkg) in pkgutil.iter_modules([path], prefix=prefix):
        module_path = os.path.join(root, name[len(package) + 1:].replace('.', os.sep) + '.py')
        load_module(module_path, name)
def load_plugins(base_type, database):