Python
Plain-English Python tests. .py.haiku files compile to pytest modules and run via pytest.
Status: available
.py.haiku files describe what a Python module or function should do in
plain English. Haiku compiles them to standard pytest modules (test_*.py)
and runs them through pytest.
Filename
<base>.py.haiku — e.g. test_parser.py.haiku, user_service.py.haiku. The
generated test file is named test_<base>.py and is written next to the
spec.
Frontmatter
| Field | Required | Notes |
|---|---|---|
intent | yes | One-line description |
sources | recommended | Ordered list of source files the test exercises, most-called first |
target.module | no | Legacy dotted module path (e.g. services.user_service) |
target.context | no | Extra module paths to feed the compiler |
Body
One natural-English assertion per line. Phrasings like "X returns Y", "X raises Z", "X is recognised as W" all work — Haiku's backend compiler keeps the grammar loose.
Running
On the first run Haiku compiles to test_test_parser.py and runs pytest
on it. On subsequent runs the generated file is reused unless the spec
changes or you pass --fresh.
Requirements
pytestavailable onPATH(or pre-installed in the venv Haiku launches in)- A
pyproject.tomlorsetup.pyancestor of the spec (so pytest's import-mode resolves your source tree)