Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_no_python_pinning #3321

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions micromamba/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,8 @@ def test_channel_alias(self, alias, existing_cache):
for to_link in res["actions"]["LINK"]:
assert to_link["channel"] == "conda-forge"

_is_on_ci = True

@pytest.mark.skipif(
(helpers.dry_run_tests is helpers.DryRun.ULTRA_DRY) or _is_on_ci,
helpers.dry_run_tests is helpers.DryRun.ULTRA_DRY,
reason="Running only ultra-dry tests",
)
def test_no_python_pinning(self, existing_cache):
Expand All @@ -440,17 +438,34 @@ 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")
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")

py_pkg = [pkg for pkg in res["actions"]["UNLINK"] if pkg["name"] == "python"][0]
assert py_pkg["version"] == ("3.9.19")
assert len(res["actions"]["UNLINK"]) == 1 # Should be setuptools
assert res["actions"]["UNLINK"][0]["name"] == "setuptools"

@pytest.mark.skipif(
helpers.dry_run_tests is helpers.DryRun.ULTRA_DRY,
Expand Down
Loading