Skip to content

Commit

Permalink
Add test case for pip hash checking mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinkens committed Apr 22, 2024
1 parent d0a8a7b commit 54faed6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test-pip-hash-checking/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# environment.yml
channels:
- conda-forge

dependencies:
- pip
- pip:
- flit-core === 3.9.0 --hash=sha256:1234
23 changes: 23 additions & 0 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 54faed6

Please sign in to comment.