Home¶
A pyrig plugin that provides pytest fixtures support.
Overview¶
pyrig-fixtures provides a library of reusable pytest fixtures for testing pyrig-managed projects. Installed as a development dependency, it makes fixtures available in every project's test suite — its own and those contributed by any installed package that depends on it — and adds a command for scaffolding new ones.
Installation¶
How it works¶
Automatic, cross-package availability¶
The generated tests/conftest.py registers pyrig-fixtures' conftest as a pytest
plugin. That conftest registers, as pytest plugins, every fixture module in
pyrig-fixtures' rig/tests/fixtures/ package and in the matching
rig/tests/fixtures/ package of every installed package that depends on
pyrig-fixtures — discovered automatically, with no registration. All discovered
fixtures are then usable in any test without an explicit import.
Fixtures therefore compose across packages: any package that depends on
pyrig-fixtures contributes fixtures simply by placing them under its own
rig/tests/fixtures/ package. Your own project is one such dependent, so the
fixtures you add there are picked up too.
Scaffolding command¶
pyrig mk fixture <name> appends a new @pytest.fixture stub to your project's
shared fixtures module under rig/tests/fixtures/, creating it if needed — a
discovered location, so the new fixture is registered and available
automatically.
End-to-end project initialization check¶
init_pyrig_project is a session-scoped, autouse fixture contributed by
pyrig-fixtures itself, so every project that depends on it runs it once per
test session automatically. It exercises the full pyrig lifecycle end to end:
building the package as a wheel, initializing a scratch project with it
installed as a pyrig plugin, and verifying that everything works as intended.
Because it does a real build, git init, and uv sync, it's slow. Pass
--skip-init-pyrig-project (or its short alias --sipp) to skip it for a
faster local feedback loop.
Running the suite under pytest-xdist
(e.g. pytest -n auto) distributes tests across several worker processes,
each of which would otherwise repeat this expensive check independently.
Only the worker named gw0 actually runs it; every other worker skips it
immediately, so the check still only runs once per overall test run.
API Reference¶
For class- and method-level details, see the API Reference, generated automatically from the source.