def METHOD_NAME(
    request,
    tmp_path_factory: pytest.TempPathFactory,
    tmp_clean_env: None,
    tmp_pkgs_dirs: pathlib.Path,
    shared_pkgs_dirs: bool,
) -> Generator[pathlib.Path, None, None]:
    """Change the micromamba root directory to a tmp folder for the duration of a test."""
    new_root_prefix = tmp_path_factory.mktemp("mamba")
    new_root_prefix.mkdir(parents=True, exist_ok=True)
    os.environ["MAMBA_ROOT_PREFIX"] = str(new_root_prefix)
    if shared_pkgs_dirs:
        os.environ["CONDA_PKGS_DIRS"] = str(tmp_pkgs_dirs)
    yield new_root_prefix
    # Pytest would clean it automatically but this can be large (0.5 Gb for repodata)
    # We clean it explicitly
    if not request.config.getoption("--no-eager-clean"):
        if new_root_prefix.exists():
            helpers.rmtree(new_root_prefix)
    # os.environ restored by tmp_clean_env and tmp_environ