def get_resource_folder_path()

in pytest_azurepipelines.py [0:0]


def get_resource_folder_path():
    resources_folder_name = "resources"
    ancestor = importlib_resources.files(__name__)

    # traverse to parent folder until a child folder with name "resources"
    # is found, or the root is reached
    while not ancestor.joinpath(resources_folder_name).is_dir():
        ancestor = ancestor.parent

        if ancestor == ancestor.parent:  # Effectively at the root
            if not (ancestor / resources_folder_name).exists():
                raise RuntimeError("Could not find the path to resources folder.")

    return os.path.join(ancestor, resources_folder_name)