From e60309cff4561a27fd2dc57b20d12a63b970039a Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 10 Dec 2023 18:39:23 +0100 Subject: [PATCH] Add failing test for conda/pip conflict Ref: #540 --- tests/test-conda-pip-conflict/environment.yml | 11 ++++++++ tests/test_conda_lock.py | 26 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/test-conda-pip-conflict/environment.yml diff --git a/tests/test-conda-pip-conflict/environment.yml b/tests/test-conda-pip-conflict/environment.yml new file mode 100644 index 00000000..af6de24e --- /dev/null +++ b/tests/test-conda-pip-conflict/environment.yml @@ -0,0 +1,11 @@ +# From @jamesmyatt: +# +channels: + - conda-forge +platforms: + - linux-64 +dependencies: + - python =3.12 + - click + - pip: + - click <8 diff --git a/tests/test_conda_lock.py b/tests/test_conda_lock.py index cb53f925..ab4a5528 100644 --- a/tests/test_conda_lock.py +++ b/tests/test_conda_lock.py @@ -1452,6 +1452,32 @@ def test_run_lock_relative_source_path( assert [p.resolve() for p in src_files] == [environment.resolve()] +@pytest.fixture +def conda_pip_conflict_environment(tmp_path: Path): + return clone_test_dir("test-conda-pip-conflict", tmp_path).joinpath( + "environment.yml" + ) + + +def test_conda_pip_conflict( + monkeypatch: pytest.MonkeyPatch, + conda_pip_conflict_environment: Path, + conda_exe: str, +): + monkeypatch.chdir(conda_pip_conflict_environment.parent) + if is_micromamba(conda_exe): + monkeypatch.setenv("CONDA_FLAGS", "-v") + run_lock([conda_pip_conflict_environment], conda_exe=conda_exe) + lockfile = parse_conda_lock_file( + conda_pip_conflict_environment.parent / DEFAULT_LOCKFILE_NAME + ) + clicks = [] + for package in lockfile.package: + if package.name == "click": + clicks.append(package) + assert len(clicks) == 1 + + @pytest.fixture def test_git_package_environment(tmp_path: Path): return clone_test_dir("test-git-package", tmp_path).joinpath("environment.yml")