Skip to content

Commit a1bfd28

Browse files
committed
fixed test expecting an error in cerr, looking into json instead
1 parent 6084967 commit a1bfd28

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

micromamba/tests/helpers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,3 +707,10 @@ def assert_state_file(state_file_path: Path, expected_state: dict):
707707
assert state[field_name] == expected_value, (
708708
f"Expected {field_name} to be {expected_value}, but got {state[field_name]}"
709709
)
710+
711+
def find_message_in_json_logs(json_result, message_to_find):
712+
for log_record in json_result["log_history"]:
713+
if message_to_find in log_record["message"]:
714+
return log_record
715+
716+
return None

micromamba/tests/test_create.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,17 @@ def test_clone_conflicts_with_specs(tmp_home, tmp_root_prefix, tmp_path):
365365
env_name = "clone-conflict-specs"
366366
helpers.create("-n", "src-env-for-conflict", "xtensor", "--json", no_dry_run=True)
367367

368-
with pytest.raises(subprocess.CalledProcessError) as info:
369-
helpers.create(
370-
"--clone",
371-
"src-env-for-conflict",
372-
"-n",
373-
env_name,
374-
"xsimd",
375-
"--json",
376-
no_dry_run=True,
377-
)
378-
stderr = info.value.stderr.decode()
379-
assert "Cannot use --clone together with package specs." in stderr
368+
res = helpers.create(
369+
"--clone",
370+
"src-env-for-conflict",
371+
"-n",
372+
env_name,
373+
"xsimd",
374+
"--json",
375+
no_dry_run=True,
376+
)
377+
378+
assert find_message_in_json_logs(res, "Cannot use --clone together with package specs.") != None
380379

381380

382381
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)

0 commit comments

Comments
 (0)