def chdir(*, target_dir: str | None = None, clone_dir: str | None = None) -> Iterator[None]:
    """Changes for the duration of the test the working directory.

    Args:
        target_dir: the target directory. If None is specified, it will create a temporary
            directory.
        clone_dir: a directory to clone into target_dir.
    Yields:
        None
    """

    cwd = os.getcwd()
    tdir = tempfile.mkdtemp() if target_dir is None else target_dir
    if clone_dir is not None:
        if Path(tdir).is_dir():
            shutil.rmtree(tdir)
        shutil.copytree(clone_dir, tdir)
    os.chdir(tdir)
    try:
        yield
    finally:
        os.chdir(cwd)
        if target_dir is None:
            shutil.rmtree(tdir)
Changes for the duration of the test the working directory.

    Args:
        target_dir: the target directory. If None is specified, it will create a temporary
            directory.
        clone_dir: a directory to clone into target_dir.
    Yields:
        None
    
dev_tools/modules_test.py