Skip to content

Commit

Permalink
Use installable tests/test_data/pixi-pypi.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Feb 26, 2025
1 parent 5ad9e1a commit f4b20b2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,25 @@ def test_missing_env(tmp_path: Path) -> None:
)


def test_no_pip_but_pypi_packages(lock_file_pypi: LockFile) -> None:
def test_no_pip_but_pypi_packages(tmp_path: Path) -> None:
"""Test the convert function with a lock file has pip packages but no pip."""
with open(PIXI_LOCK_PYPI_PATH) as f:
data = yaml.safe_load(f)

for env, env_data in data["environments"].items():
for platform, package_data in env_data["packages"].items():
remove = []
for i, dct in enumerate(package_data):
if "conda" in dct and "/pip-" in dct["conda"]:
remove.append(i)
for i in reversed(remove):
del data["environments"][env]["packages"][platform][i]
new_lock_path = tmp_path / "pixi.lock"
with open(new_lock_path, "w") as f:
yaml.safe_dump(data, f)
lock_file = LockFile.from_path(new_lock_path)
with pytest.raises(
ValueError,
match="PyPI packages are present but no pip package found in conda packages.",
):
_convert_env_to_conda_lock(lock_file_pypi, "default")
_convert_env_to_conda_lock(lock_file, "default")
15 changes: 15 additions & 0 deletions tests/test_data/pixi-pypi.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/osx-64/libzlib-1.3.1-hd23fc13_2.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/ncurses-6.5-h0622a9a_3.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/openssl-3.4.1-hc426f3f_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pip-25.0.1-pyh145f28c_0.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/python-3.13.2-h534c281_101_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/python_abi-3.13-5_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/readline-8.2-h7cca4af_2.conda
Expand All @@ -43,6 +44,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libzlib-1.3.1-h8359307_2.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/ncurses-6.5-h5e97a16_3.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/openssl-3.4.1-h81ee809_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pip-25.0.1-pyh145f28c_0.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.13.2-h81fe080_101_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/python_abi-3.13-5_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.2-h1d1bf99_2.conda
Expand All @@ -66,6 +68,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/osx-64/libzlib-1.3.1-hd23fc13_2.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/ncurses-6.5-h0622a9a_3.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/openssl-3.4.1-hc426f3f_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pip-25.0.1-pyh145f28c_0.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/python-3.13.2-h534c281_101_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/python_abi-3.13-5_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-64/readline-8.2-h7cca4af_2.conda
Expand All @@ -83,6 +86,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libzlib-1.3.1-h8359307_2.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/ncurses-6.5-h5e97a16_3.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/openssl-3.4.1-h81ee809_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pip-25.0.1-pyh145f28c_0.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.13.2-h81fe080_101_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/python_abi-3.13-5_cp313.conda
- conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.2-h1d1bf99_2.conda
Expand Down Expand Up @@ -350,6 +354,17 @@ packages:
purls: []
size: 2934522
timestamp: 1739301896733
- conda: https://conda.anaconda.org/conda-forge/noarch/pip-25.0.1-pyh145f28c_0.conda
sha256: b1beb97b230321fc2ae692bd631cd65530c59686151af9d11aaa16df815f9ee8
md5: 9ba21d75dc722c29827988a575a65707
depends:
- python >=3.13.0a0
license: MIT
license_family: MIT
purls:
- pkg:pypi/pip?source=hash-mapping
size: 1256777
timestamp: 1739142856473
- conda: https://conda.anaconda.org/conda-forge/osx-64/python-3.13.2-h534c281_101_cp313.conda
build_number: 101
sha256: 19abb6ba8a1af6985934a48f05fccd29ecc54926febdb8b3803f30134c518b34
Expand Down

0 comments on commit f4b20b2

Please sign in to comment.