Skip to content

Commit

Permalink
Increase testing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Feb 26, 2025
1 parent 1812557 commit 45518db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pixi_to_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _setup_logging(verbose: bool = False) -> None: # noqa: FBT001, FBT002
from rich.logging import RichHandler

handlers = [RichHandler(rich_tracebacks=True)]
except ImportError:
except ImportError: # pragma: no cover
handlers = [logging.StreamHandler()]

log_level = logging.DEBUG if verbose else logging.INFO
Expand Down Expand Up @@ -114,7 +114,7 @@ def _create_pypi_package_entry(
) -> dict[str, Any]:
"""Create a conda-lock package entry from a PypiLockedPackage."""
hashes = package.hashes
if not hashes:
if not hashes: # pragma: no cover
msg = f"Package {package.name} has no hashes"
raise ValueError(msg)
return {
Expand Down
10 changes: 10 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,13 @@ def test_convert(tmp_path: Path) -> None:
PIXI_LOCK_PATH,
conda_lock_path=output,
)


def test_missing_env(tmp_path: Path) -> None:
"""Test the convert function with a missing environment."""
with pytest.raises(ValueError, match="not found in pixi.lock file"):
convert(
PIXI_LOCK_PATH,
conda_lock_path=tmp_path / "conda-lock.yml",
environment="nonexistent",
)

0 comments on commit 45518db

Please sign in to comment.