Added test detecting failure when cleaning removed packages.

This commit is contained in:
Joël Lamotte (Klaim) 2022-10-03 18:40:27 +02:00
parent 41cfe05d38
commit 3625231fd3
2 changed files with 32 additions and 0 deletions

View File

@ -195,6 +195,28 @@ def remove(*args, no_dry_run=False):
raise (e)
def clean(*args, no_dry_run=False):
umamba = get_umamba()
cmd = [umamba, "clean", "-y"] + [arg for arg in args if arg]
if "--print-config-only" in args:
cmd += ["--debug"]
if (dry_run_tests == DryRun.DRY) and "--dry-run" not in args and not no_dry_run:
cmd += ["--dry-run"]
try:
res = subprocess.check_output(cmd)
if "--json" in args:
j = json.loads(res)
return j
if "--print-config-only" in args:
return yaml.load(res, Loader=yaml.FullLoader)
return res.decode()
except subprocess.CalledProcessError as e:
print(f"Error when executing '{' '.join(cmd)}'")
raise (e)
def update(*args, default_channel=True, no_rc=True, no_dry_run=False):
umamba = get_umamba()
cmd = [umamba, "update", "-y"] + [arg for arg in args if arg]

View File

@ -242,6 +242,16 @@ class TestRemoveConfig:
assert res["env_name"] == ""
assert res["specs"] == specs
def test_remove_then_clean(self, env_created):
from .test_create import test_env_requires_pip_install_path
env_name = "env_to_clean"
create(
"-n", env_name, "-f", test_env_requires_pip_install_path, no_dry_run=True
)
remove("-n", env_name, "pip", no_dry_run=True)
clean("-ay", no_dry_run=True)
@pytest.mark.parametrize("root_prefix", (None, "env_var", "cli"))
@pytest.mark.parametrize("target_is_root", (False, True))
@pytest.mark.parametrize("cli_prefix", (False, True))