From b272ad5d5a129bbaece3e44413b66da35e13a33d Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Tue, 10 Sep 2024 20:27:51 +0200 Subject: [PATCH] Use a quicker example for the channel-inversion test --- tests/test-channel-inversion/environment.yaml | 7 +++--- tests/test_conda_lock.py | 22 +++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/test-channel-inversion/environment.yaml b/tests/test-channel-inversion/environment.yaml index 1e8acb45..1562a90a 100644 --- a/tests/test-channel-inversion/environment.yaml +++ b/tests/test-channel-inversion/environment.yaml @@ -4,9 +4,8 @@ channels: # In this case we have the channel order as recommended by rapids ai for # installing cudf, but we want to force getting cuda-python from conda-forge # instead of from the nvidia channel which would normally have higher priority - - rapidsai - - nvidia - conda-forge + - defaults dependencies: - - cudf - - conda-forge::cuda-python \ No newline at end of file + - zlib + - defaults::libgomp diff --git a/tests/test_conda_lock.py b/tests/test_conda_lock.py index 433d290e..2f999fa5 100644 --- a/tests/test_conda_lock.py +++ b/tests/test_conda_lock.py @@ -1665,22 +1665,30 @@ def test_poetry_version_parsing_constraints( def test_run_with_channel_inversion( monkeypatch: "pytest.MonkeyPatch", channel_inversion: Path, mamba_exe: str ): - """Given that the cuda_python package is available from a few channels - and three of those channels listed - and with conda-forge listed as the lowest priority channel - and with the cuda_python dependency listed as "conda-forge::cuda_python", - ensure that the lock file parse picks up conda-forge as the channel and not one of the higher priority channels + """Given that the libgomp package is available from a few channels + and two of those channels listed + and with defaults listed as the lowest priority channel + and with the libgomp dependency listed as "defaults::libgomp", + ensure that the lock file parse picks up "defaults" as the channel and not + the higher priority conda-forge channel. """ monkeypatch.chdir(channel_inversion.parent) run_lock([channel_inversion], conda_exe=mamba_exe, platforms=["linux-64"]) lockfile = parse_conda_lock_file(channel_inversion.parent / DEFAULT_LOCKFILE_NAME) for package in lockfile.package: - if package.name == "cuda-python": + if package.name == "zlib": ms = MatchSpec(package.url) # pyright: ignore assert ms.get("channel") == "conda-forge" break else: - raise ValueError("cuda-python not found!") + raise ValueError("zlib not found!") + for package in lockfile.package: + if package.name == "libgomp": + ms = MatchSpec(package.url) # pyright: ignore + assert ms.get("channel") == "defaults" + break + else: + raise ValueError("libgomp not found!") def _make_spec(name: str, constraint: str = "*"):