Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
SandrineP committed Jan 29, 2025
1 parent 7f0708a commit 260feaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
4 changes: 2 additions & 2 deletions libmamba/src/api/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ namespace mamba
{
if (options.canonical)
{
std::cout << "Warning: Option --canonical ignored because of --explicit \n"
<< std::endl;
LOG_WARNING << "Warning: Option --canonical ignored because of --explicit"
<< std::endl;
}
for (auto p : packages)
{
Expand Down
43 changes: 18 additions & 25 deletions micromamba/tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,25 @@ def test_list_no_json(

@pytest.mark.parametrize("explicit_flag", ["", "--explicit"])
@pytest.mark.parametrize("md5_flag", ["", "--md5"])
@pytest.mark.parametrize("canonical_flag", ["", "-c", "--canonical"])
@pytest.mark.parametrize("env_selector", ["", "name", "prefix"])
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_list_explicit(
tmp_home, tmp_root_prefix, tmp_env_name, tmp_xtensor_env, env_selector, explicit_flag, md5_flag
def test_list_subcommands(
tmp_home,
tmp_root_prefix,
tmp_env_name,
tmp_xtensor_env,
env_selector,
explicit_flag,
md5_flag,
canonical_flag,
):
if env_selector == "prefix":
res = helpers.umamba_list("-p", tmp_xtensor_env, explicit_flag, md5_flag)
res = helpers.umamba_list("-p", tmp_xtensor_env, explicit_flag, md5_flag, canonical_flag)
elif env_selector == "name":
res = helpers.umamba_list("-n", tmp_env_name, explicit_flag, md5_flag)
res = helpers.umamba_list("-n", tmp_env_name, explicit_flag, md5_flag, canonical_flag)
else:
res = helpers.umamba_list(explicit_flag, md5_flag)
res = helpers.umamba_list(explicit_flag, md5_flag, canonical_flag)

outputs_list = res.strip().split("\n")[2:]
if explicit_flag == "--explicit":
Expand All @@ -101,27 +109,12 @@ def test_list_explicit(
assert "#" in output
else:
assert "#" not in output


@pytest.mark.parametrize("canonical_flag", ["", "--canonical"])
@pytest.mark.parametrize("env_selector", ["", "name", "prefix"])
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_list_canonical(
tmp_home, tmp_root_prefix, tmp_env_name, tmp_xtensor_env, env_selector, canonical_flag
):
if env_selector == "prefix":
res = helpers.umamba_list("-p", tmp_xtensor_env, canonical_flag)
elif env_selector == "name":
res = helpers.umamba_list("-n", tmp_env_name, canonical_flag)
else:
res = helpers.umamba_list(canonical_flag)

outputs_list = res.strip().split("\n")[2:]
if canonical_flag == "--canonical":
items = ["conda-forge/", "::"]
for output in outputs_list:
assert all(i in output for i in items)
assert " " not in output
if canonical_flag == "--canonical":
items = ["conda-forge/", "::"]
for output in outputs_list:
assert all(i in output for i in items)
assert " " not in output


@pytest.mark.parametrize("quiet_flag", ["", "-q", "--quiet"])
Expand Down

0 comments on commit 260feaf

Please sign in to comment.