Skip to main content
Install varianz-pytest (instructions) and the plugin auto-registers via entry points — no conftest.py changes needed. Run pytest with the standard environment: VARIANZ_ENABLED=true, plus VARIANZ_INSECURE_ALLOW_PLAINTEXT=true for a plaintext local coordinator. Endpoint: --varianz-endpoint <url> → VARIANZ_COORDINATOR_ENDPOINT → endpoint in varianz.toml → http://localhost:50051. The deprecated VARIANZ_COORDINATOR_ADDR is still read when the canonical name is unset, with a DeprecationWarning; it is removed before 1.0.

The varianz fixture

A fresh VarianzSession per test — created, activated for the test body, and torn down (stages removed) automatically:
Python’s requests strips custom headers when following redirects. Always use a requests.Session() with x-varianz-id set on the session object, not per-call headers=.
pytest hides Varianz’s validation warnings by default. They are written to stderr at session teardown, which pytest captures and discards for a passing test — so a green run on a laptop shows nothing at all. Run pytest -rA (or -s / --capture=no) to see them, and put -rA in your CI invocation. A stage that silently never applied is otherwise indistinguishable from one that worked.

Session API

Sample assertions

In-process calls

The fixture activates its session for the duration of the test body, so code running in the same process as pytest matches your stages with no extra wiring — just call the instrumented function:
(The session rides a contextvar, so it follows asyncio tasks started from the test as well.)
If the VPoint you’re testing runs in the pytest process and you don’t need session isolation, skip the fixture entirely: vz.attach_stage(...) takes a plain Python callback and needs no coordinator, no session, and no sync barrier. See Local stages.
For creating stages, cel(target, expression) is the only constructor you need — targets and routing filters are described in Naming and routing.