def validate_namespace_package(
    pytester: Pytester, paths: Sequence[Path], modules: Sequence[str]
) -> RunResult:
    """
    Validate that a Python namespace package is set up correctly.

    In a sub interpreter, add 'paths' to sys.path and attempt to import the given modules.

    In this module many tests configure a set of files as a namespace package, this function
    is used as sanity check that our files are configured correctly from the point of view of Python.
    """
    lines = [
        "import sys",
        # Configure sys.path.
        *[f"sys.path.append(r{str(x)!r})" for x in paths],
        # Imports.
        *[f"import {x}" for x in modules],
    ]
    return pytester.runpython_c("\n".join(lines))

    Validate that a Python namespace package is set up correctly.

    In a sub interpreter, add 'paths' to sys.path and attempt to import the given modules.

    In this module many tests configure a set of files as a namespace package, this function
    is used as sanity check that our files are configured correctly from the point of view of Python.
    
testing/test_pathlib.py