From b0fafa6ef4e7028252d9f8099793ce9b4ea57f63 Mon Sep 17 00:00:00 2001 From: Hind-M <70631848+Hind-M@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:45:54 +0200 Subject: [PATCH] [1.x] Fix test (#3432) Backport #3321 from main --- micromamba/tests/test_install.py | 37 ++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/micromamba/tests/test_install.py b/micromamba/tests/test_install.py index 9a9eef02a6..7704644f4c 100644 --- a/micromamba/tests/test_install.py +++ b/micromamba/tests/test_install.py @@ -449,17 +449,42 @@ def test_no_python_pinning(self, existing_cache): action_keys = {"LINK", "UNLINK", "PREFIX"} assert action_keys.issubset(set(res["actions"].keys())) - expected_link_packages = {"python"} + # When using `--no-py-pin`, it may or may not update the already installed + # python version, but `python_abi` is installed in any case + # The following tests/assertions consider both cases + expected_link_packages = {"python_abi"} link_packages = {pkg["name"] for pkg in res["actions"]["LINK"]} assert expected_link_packages.issubset(link_packages) + unlink_packages = {pkg["name"] for pkg in res["actions"]["UNLINK"]} - assert {"python"}.issubset(unlink_packages) + if {"python"}.issubset(link_packages): + assert {"python"}.issubset(unlink_packages) - py_pkg = [pkg for pkg in res["actions"]["LINK"] if pkg["name"] == "python"][0] - assert py_pkg["version"] != ("3.9.19") + py_pkg = [pkg for pkg in res["actions"]["LINK"] if pkg["name"] == "python"][ + 0 + ] + assert py_pkg["version"] != ("3.9.19") - py_pkg = [pkg for pkg in res["actions"]["UNLINK"] if pkg["name"] == "python"][0] - assert py_pkg["version"] == ("3.9.19") + py_pkg = [ + pkg for pkg in res["actions"]["UNLINK"] if pkg["name"] == "python" + ][0] + assert py_pkg["version"] == ("3.9.19") + else: + assert ( + len(res["actions"]["LINK"]) == 2 + ) # Should be setuptools and python_abi + + py_abi_pkg = [ + pkg for pkg in res["actions"]["LINK"] if pkg["name"] == "python_abi" + ][0] + assert py_abi_pkg["version"] == ("3.9") + setuptools_pkg = [ + pkg for pkg in res["actions"]["LINK"] if pkg["name"] == "setuptools" + ][0] + assert setuptools_pkg["version"] == ("63.4.3") + + assert len(res["actions"]["UNLINK"]) == 1 # Should be setuptools + assert res["actions"]["UNLINK"][0]["name"] == "setuptools" @pytest.mark.skipif( dry_run_tests is DryRun.ULTRA_DRY, reason="Running only ultra-dry tests"