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

Amend test suite for compatibility with libmamba v2 #13784

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions conda/testing/solver_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import functools
import json
import pathlib
import time
from tempfile import TemporaryDirectory

import pytest
Expand Down Expand Up @@ -707,6 +708,9 @@ def test_nonexistent_deps(self, env):
"test::pip-1.3.1-py33_1",
}

# Add 1s to make sure the new repodata.jsons have different mod times
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Add 1s to make sure the new repodata.jsons have different mod times
# Add 1s to make sure the new repodata.jsons have different mod times
# To be fixed by https://github.com/conda/conda/issues/13783

time.sleep(1)

# This time, the latest version is messed up
env.repo_packages = index_packages(1) + [
helpers.record(
Expand Down
32 changes: 23 additions & 9 deletions tests/core/test_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause
import copy
import os
import re
import sys
from pprint import pprint
from unittest.mock import Mock, patch
Expand Down Expand Up @@ -2692,6 +2693,14 @@ def test_timestamps_1(tmpdir):


def test_channel_priority_churn_minimized(tmpdir):
"""
get_solver_aggregate_2 has [channel-4, channel-2].
When the channels are reverted in the second operation, we put
channel-2 first. Under these circumstances, reinstalling
'itsdangerous' should pick the noarch version from channel-2
instead of the non-noarch variant in channel-4. Everything
else should stay the same due to FREEZE_INSTALLED.
"""
specs = (
MatchSpec("conda-build"),
MatchSpec("itsdangerous"),
Expand All @@ -2701,6 +2710,12 @@ def test_channel_priority_churn_minimized(tmpdir):

pprint(convert_to_dist_str(final_state))

if context.solver == "libmamba":
# With libmamba v2, we need this extra flag to make this test pass
# Otherwise, the solver considers the current state as satisfying.
solver_kwargs = {"force_reinstall": True}
else:
solver_kwargs = {}
with get_solver_aggregate_2(
tmpdir,
[MatchSpec("itsdangerous")],
Expand All @@ -2709,7 +2724,8 @@ def test_channel_priority_churn_minimized(tmpdir):
) as solver:
solver.channels.reverse()
unlink_dists, link_dists = solver.solve_for_diff(
update_modifier=UpdateModifier.FREEZE_INSTALLED
update_modifier=UpdateModifier.FREEZE_INSTALLED,
**solver_kwargs,
)
pprint(convert_to_dist_str(unlink_dists))
pprint(convert_to_dist_str(link_dists))
Expand Down Expand Up @@ -3076,9 +3092,7 @@ def test_freeze_deps_1(tmpdir):
(
"channel-2::six-1.7.3-py34_0",
"channel-2::python-3.4.5-0",
# LIBMAMBA ADJUSTMENT
# libmamba doesn't remove xz in this solve
*(() if context.solver == "libmamba" else ("channel-2::xz-5.2.3-0",)),
"channel-2::xz-5.2.3-0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2 fixed this solver difference. We can still bring it back with this change, though.

)
)
link_order = add_subdir_to_iter(
Expand Down Expand Up @@ -3282,12 +3296,12 @@ def test_downgrade_python_prevented_with_sane_message(tmpdir):
error_snippets = [
"Encountered problems while solving",
"Pins seem to be involved in the conflict. Currently pinned specs",
"python 2.6.*",
"scikit-learn 0.13",
r"python.*2\.6",
r"scikit-learn.*0\.13",
]

for snippet in error_snippets:
assert snippet in error_msg
assert re.search(snippet, error_msg)

specs_to_add = (MatchSpec("unsatisfiable-with-py26"),)
with get_solver(
Expand All @@ -3310,12 +3324,12 @@ def test_downgrade_python_prevented_with_sane_message(tmpdir):
error_snippets = [
"Encountered problems while solving",
"Pins seem to be involved in the conflict. Currently pinned specs",
"python 2.6.*",
r"python.*2\.6",
"unsatisfiable-with-py26",
]

for snippet in error_snippets:
assert snippet in error_msg
assert re.search(snippet, error_msg)


fake_index = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def bash_unsupported() -> str | None:


skip_unsupported_bash = pytest.mark.skipif(
bash_unsupported(),
bool(bash_unsupported()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a recent pytest release got stricter about the types here.

reason=bash_unsupported() or "bash: supported!",
)
skip_unsupported_posix_path = pytest.mark.skipif(
Expand Down