diff --git a/micromamba/tests/test_create.py b/micromamba/tests/test_create.py index 93d88190af..31c55c2432 100644 --- a/micromamba/tests/test_create.py +++ b/micromamba/tests/test_create.py @@ -666,19 +666,19 @@ def test_create_envs_dirs(tmp_root_prefix: Path, tmp_path: Path, monkeypatch): noperm_root_dir = Path(tmp_path / "noperm") noperm_envs_dir = noperm_root_dir / "envs" + # On Windows, use a different root prefix to avoid permission issues. + if platform.system() == "Windows": + noperm_envs_dir = Path("C:\\no_perms\\envs") + else: + # Make the root dir not writable. + os.makedirs(noperm_root_dir, mode=stat.S_IRUSR) monkeypatch.setenv("CONDA_ENVS_DIRS", f"{noperm_envs_dir},{tmp_path}") env_name = "myenv" - os.makedirs(noperm_root_dir, exist_ok=True) - try: - # Make the first envs dir not writable, readable, nor executable. - current_perms = stat.S_IMODE(os.stat(noperm_root_dir).st_mode) - os.chmod(noperm_root_dir, stat.S_IRUSR) - helpers.create("-n", env_name, "--offline", "--no-rc", no_dry_run=True) - finally: - os.chmod(noperm_root_dir, current_perms) + helpers.create("-n", env_name, "--offline", "--no-rc", no_dry_run=True) + assert not (noperm_envs_dir / env_name).exists() assert (tmp_path / env_name / "conda-meta" / "history").exists()