diff --git a/tests/test-pip-hash-checking/environment.yml b/tests/test-pip-hash-checking/environment.yml new file mode 100644 index 000000000..9d80160e9 --- /dev/null +++ b/tests/test-pip-hash-checking/environment.yml @@ -0,0 +1,8 @@ +# environment.yml +channels: + - conda-forge + +dependencies: + - pip + - pip: + - flit-core === 3.9.0 --hash=sha256:1234 diff --git a/tests/test_conda_lock.py b/tests/test_conda_lock.py index a38edb67b..94b116674 100644 --- a/tests/test_conda_lock.py +++ b/tests/test_conda_lock.py @@ -156,6 +156,13 @@ def pip_environment_different_names_same_deps(tmp_path: Path): ) +@pytest.fixture +def pip_hash_checking_environment(tmp_path: Path): + return clone_test_dir("test-pip-hash-checking", tmp_path).joinpath( + "environment.yml" + ) + + @pytest.fixture def pip_local_package_environment(tmp_path: Path): return clone_test_dir("test-local-pip", tmp_path).joinpath("environment.yml") @@ -1508,6 +1515,22 @@ def test_run_lock_with_pip_environment_different_names_same_deps( run_lock([pip_environment_different_names_same_deps], conda_exe=conda_exe) +def test_run_lock_with_pip_hash_checking( + monkeypatch: "pytest.MonkeyPatch", + pip_hash_checking_environment: Path, + conda_exe: str, +): + work_dir = pip_hash_checking_environment.parent + monkeypatch.chdir(work_dir) + if is_micromamba(conda_exe): + monkeypatch.setenv("CONDA_FLAGS", "-v") + run_lock([pip_hash_checking_environment], conda_exe=conda_exe) + + lockfile = parse_conda_lock_file(work_dir / DEFAULT_LOCKFILE_NAME) + hashes = {package.name: package.hash for package in lockfile.package} + assert hashes["flit-core"].sha256 == "1234" + + def test_run_lock_uppercase_pip( monkeypatch: "pytest.MonkeyPatch", env_with_uppercase_pip: Path,