Skip to content

Commit

Permalink
Add tests with no env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Hind-M committed Sep 10, 2024
1 parent 98a053a commit da1ea7d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
27 changes: 26 additions & 1 deletion micromamba/tests/test_install.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import platform
import shutil
import subprocess
import sys
import platform
from pathlib import Path

import pytest
Expand Down Expand Up @@ -202,11 +202,36 @@ def test_target_prefix_with_no_settings(
# Specify no arg
cmd = []

# Get the actual set MAMBA_ROOT_PREFIX when setting up `TestInstall` class
os.environ["MAMBA_DEFAULT_ROOT_PREFIX"] = os.environ.pop("MAMBA_ROOT_PREFIX")
os.environ.pop("CONDA_PREFIX")

# Fallback on root prefix
res = helpers.install(*cmd, "--print-config-only")

TestInstall.config_tests(
res,
root_prefix=TestInstall.root_prefix,
target_prefix=TestInstall.root_prefix,
)

@pytest.mark.skipif(
sys.platform == "win32",
reason="MAMBA_ROOT_PREFIX is set in windows GH workflow",
)
def test_target_prefix_with_no_settings_and_no_env_var(
self,
existing_cache,
):
# Specify no arg
cmd = []

os.environ.pop("MAMBA_ROOT_PREFIX")
os.environ.pop("CONDA_PREFIX")

# Fallback on root prefix
res = helpers.install(*cmd, "--print-config-only")

TestInstall.config_tests(
res,
root_prefix=TestInstall.current_root_prefix,
Expand Down
25 changes: 25 additions & 0 deletions micromamba/tests/test_update.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import platform
import shutil
import sys
from pathlib import Path

import pytest
Expand Down Expand Up @@ -394,11 +395,35 @@ def test_target_prefix_with_no_settings(
# Specify no arg
cmd = []

# Get the actual set MAMBA_ROOT_PREFIX when setting up `TestUpdateConfig` class
os.environ["MAMBA_DEFAULT_ROOT_PREFIX"] = os.environ.pop("MAMBA_ROOT_PREFIX")
os.environ.pop("CONDA_PREFIX")

# Fallback on root prefix
res = helpers.install(*cmd, "--print-config-only")
TestUpdateConfig.config_tests(
res,
root_prefix=TestUpdateConfig.root_prefix,
target_prefix=TestUpdateConfig.root_prefix,
)

@pytest.mark.skipif(
sys.platform == "win32",
reason="MAMBA_ROOT_PREFIX is set in windows GH workflow",
)
def test_target_prefix_with_no_settings_and_no_env_var(
self,
existing_cache,
):
# Specify no arg
cmd = []

os.environ.pop("MAMBA_ROOT_PREFIX")
os.environ.pop("CONDA_PREFIX")

# Fallback on root prefix
res = helpers.install(*cmd, "--print-config-only")

TestUpdateConfig.config_tests(
res,
root_prefix=TestUpdateConfig.current_root_prefix,
Expand Down

0 comments on commit da1ea7d

Please sign in to comment.