Skip to content

Commit

Permalink
Yet another approach
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Feb 24, 2025
1 parent a0318d6 commit 7c6a92a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions micromamba/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "C:\\no_perms\\envs"
else:
# Make the root dir not writable, not readable, nor executable by the user.
os.makedirs(noperm_root_dir, mode=stat.S_IWOTH)

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()


Expand Down

0 comments on commit 7c6a92a

Please sign in to comment.