From b240d83f113a9f1fc05d3344b69d408e259834a0 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Wed, 18 Sep 2024 16:04:21 +0200 Subject: [PATCH] Fix test --- micromamba/tests/test_env.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/micromamba/tests/test_env.py b/micromamba/tests/test_env.py index 2c202189e0..2f6feca08e 100644 --- a/micromamba/tests/test_env.py +++ b/micromamba/tests/test_env.py @@ -1,6 +1,8 @@ import os import re import shutil + +from packaging.version import Version from pathlib import Path import pytest @@ -152,8 +154,6 @@ def test_env_update(tmp_home, tmp_root_prefix, tmp_path, prune): assert not any(package["name"] == "ipython" for package in packages) # Update python - from packaging.version import Version - env_file_yml = tmp_path / "test_env.yaml" env_file_yml.write_text(env_yaml_content_with_version_and_new_pkg) @@ -361,5 +361,12 @@ def test_env_update_pypi_with_conda_forge(tmp_home, tmp_root_prefix, tmp_path): ## See: https://github.com/mamba-org/mamba/issues/2059 pip_list_output = helpers.umamba_run("-p", env_prefix, "pip", "list", "--format=json") pip_packages_list = yaml.safe_load(pip_list_output) - - assert any(pkg["name"] == "numpy" and pkg["version"] == "1.26.4" for pkg in pip_packages_list) + # When numpy 2.0.0 is installed using mamba, + # `numpy-2.0.0.dist-info/` is still created in `env_prefix/lib/pythonx.x/site-packages/` alongside `numpy-1.26.4.dist-info` + # therefore causing an unexpected result when listing the version. + # In an ideal world, multiple package managers shouldn't be mixed but since this is supported, tests are here + # (note that a warning is printed to the user in that case) + assert any( + pkg["name"] == "numpy" and Version(pkg["version"]) >= Version("1.26.4") + for pkg in pip_packages_list + )