Pydust ships with a Pytest plugin that builds, collects and executes your Zig tests. This means testing should work out-of-the-box with your existing Python project and you never need to interact directly with the Zig build system if you don't want to.
The Zig documentation provides an excellent introduction to writing tests.
Zig tests are currently spawned as a separate process. This means you must manually call
defer py.finalize() in order to setup and teardown a Python interpreter.
ziggy-pydust as a dev dependency:
Keep this version the same as build dependency version. There is currently no way to guarantee this with Poetry.
poetry run pytest you should see your Zig tests included in your Pytest output:
================================== test session starts ==================================
platform darwin -- Python 3.11.5, pytest-7.4.0, pluggy-1.3.0
collected 7 items
example/pytest.zig .x [100%]
============================= 1 passed, 1 xfailed in 0.30s ==============================