Skip to content

About

A pytest plugin that runs shared conda solver YAML tests against classic, libmamba, or other conda solver backends.

Resources

Code of conduct

Stars

0 stars

Watchers

2 watching

Forks

Repository files navigation

pytest-conda-solvers

PyPI version Python versions Documentation

A pytest plugin that runs shared conda solver YAML tests against classic, libmamba, or other conda solver backends.

The PyPI package ships the plugin, fixtures, mock channel data, and shared YAML suite under pytest_conda_solvers/. When the plugin loads, it automatically adds the bundled suite to pytest's collection.

conda-solver-tests pytest plugin was orginally generated with [Cookiecutter] along with [@hackebrot]'s [cookiecutter-pytest-plugin] template.

Error assertion semantics

For unsatisfiable tests, this suite deliberately asserts more than conda's own test suite does when running under conda-libmamba-solver. Upstream's assert_unsatisfiable helper only checks the exception is an UnsatisfiableError subclass there, because its entries comparison is gated on the exact UnsatisfiableError type. Our runner additionally checks that the endpoint package names of each expected conflict chain appear in the libmamba error message, and message_includes/message_excludes fields in the YAML add further content checks (either a list that applies to every solver, or a mapping keyed by solver name where upstream asserts solver-specific messages). This strengthening is intentional: cross-solver consistency of error reporting is part of what this plugin exists to verify. The endpoint-name check applies to libmamba only. Other solvers word their messages differently (rattler may omit the requested package entirely), so for them only the explicit message_includes/message_excludes fields apply, matching upstream's type-only check.

Solver applicability under rattler

conda-rattler-solver skips the feature-dependent tests of conda's shared SolverTests suite ("conda-rattler-solver does not support features", see https://github.com/conda/conda-rattler-solver/blob/main/tests/test_solver.py). Those tests are already restricted to the classic solver in this suite, so they are skipped under --conda-solver=rattler automatically. Known rattler limitations beyond that (flexible channel priority) are carried as strict per-entry xfail_solvers: rattler marks, so CI notices when an upstream fix lands.

Tests with add_pip: true need no such marks. For them the channel server serves pip-injected repodata under a parallel /with-pip route, where every python 2.x/3.x record gains a pip dependency at index level, exactly like upstream's test fixtures. The injection therefore reaches solvers that read repodata directly, such as rattler, without relying on conda's add_pip_as_python_dependency setting at solve time. The route is a stopgap until conda-rattler-solver honours the setting itself, tracked in conda-rattler-solver#122.

Requirements

  • Python ≥ 3.11
  • A working conda (>=26.9.4) installation in the environment (install via conda, mamba, or pixi — not from PyPI)
  • The solver backend under test (for example conda-libmamba-solver)

Installation

conda create -n solver-test-env conda conda-libmamba-solver pip
conda activate solver-test-env
python -m pip install pytest-conda-solvers

For local development from a checkout:

pixi install
# or: pip install -e .

Usage

Select a solver with --conda-solver; the bundled suite is collected automatically:

pytest --conda-solver=libmamba
pytest --conda-solver=classic

Paths passed to pytest are collected alongside the bundled suite, so solver authors can add their own Python or YAML tests normally.

Use --no-bundled-solver-tests to collect custom tests without the suite shipped by this package.

From this repository with pixi:

pixi run test-libmamba-solver
pixi run test-classic-solver

The plugin collects solver-suite .yaml files, starts a session-scoped mock channel server, and runs each case through the selected solver backend.

Contributing

Contributions are welcome. It is recommended to use pixi for the development environment and run the solver test tasks above before opening a pull request.

Build the documentation locally with pixi run -e docs docs-build.

License

Distributed under the BSD-3-Clause license.

Issues

If you encounter problems, please file an issue.

About

A pytest plugin that runs shared conda solver YAML tests against classic, libmamba, or other conda solver backends.

Resources

Code of conduct

Stars

0 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages