def METHOD_NAME(path):
    """Change the current working directory temporarily."""
    path = Path(path).expanduser()
    prev_path = Path(getcwd())
    cwd_lock = "./.mp_test_cwd.lock"
    try:
        with FileLock(cwd_lock):
            chdir(str(path))
            yield
    finally:
        chdir(str(prev_path))
        if Path(cwd_lock).is_file():
            with suppress(Exception):
                Path(cwd_lock).unlink()