def METHOD_NAME(tmp_path):
    ud = tmp_path / "userdir"
    ud.mkdir(exist_ok=True)
    if sys.platform.startswith("win"):
        user_dir_env = "LOCALAPPDATA"
    else:
        user_dir_env = "IMAGEIO_USERDIR"
    old_user_dir = os.getenv(user_dir_env, None)
    os.environ[user_dir_env] = str(ud)
    yield ud
    if old_user_dir is not None:
        os.environ[user_dir_env] = old_user_dir
    else:
        del os.environ[user_dir_env]