JSON output¶
Every xpt command takes --json and prints one JSON object on stdout. pytest --xpt-json=PATH writes the whole pytest report the same way. Each object has "schema_version": 1.
Values¶
Values use xpt's recorded form. It is plain JSON where JSON can say the type, and a one-key object where it can't:
| Python | JSON |
|---|---|
{"a": [1, 2.5, True, None]} |
{"dict": {"a": [1, 2.5, true, null]}} |
(1,) |
{"tuple": [1]} |
{1: "x"} |
{"dict": [[1, "x"]]} |
float("nan") |
{"float": "nan"} |
Point(1, "a") from module values |
{"values:Point": {"x": 1, "y": "a"}} |
expected is left out when there is none, so a recorded None stays distinct from a missing expectation.
Group¶
xpt failures --json returns the run and its groups. Each group is one call site:
{
"schema_version": 1,
"command": "failures",
"run": "20261119T150800-b910",
"groups": [
{
"id": "0eae",
"site": {"path": "tests/test_demo.py", "line": 5, "qualname": "test_count"},
"status": "mismatch",
"acceptable": true,
"rejected": false,
"tests": ["tests/test_demo.py::test_count"],
"detail": "",
"actuals": [{"dict": {"status": "ok", "count": 4}}],
"expected": {"dict": {"status": "ok", "count": 3}},
"changes": [
{"path": "value[\"count\"]", "op": "replace", "expected": 3, "actual": 4}
],
"unchanged": 1
}
]
}
statusis one ofmissing,mismatch,conflict,unsupported, orunlocatable.acceptableis true formissingandmismatch.detailsays why a group can't be accepted.actualsholds the distinct actual values, one when every call agreed.changesandunchangedappear on a mismatch.opisreplace,add, orremove.
xpt show ID --json returns one group in the same form.
Accept and reject¶
{
"schema_version": 1,
"command": "accept",
"run": "20261119T150800-b910",
"dry_run": true,
"outcomes": [
{"id": "0eae", "site": {"path": "tests/test_demo.py", "line": 5, "qualname": "test_count"},
"status": "accepted", "reason": ""}
],
"changed": ["tests/test_demo.py"]
}
An accept outcome's status is accepted, already_accepted, stale, or skipped, and reason says why it wasn't written. xpt reject --json has the same outcomes, with rejected, already_rejected, or skipped, and no changed.
Runs¶
{
"schema_version": 1,
"command": "runs",
"runs": [
{"id": "20261119T150800-b910", "latest": true, "failures": 1}
]
}
pytest --xpt-json¶
{
"schema_version": 1,
"exit_code": 1,
"summary": "1 failed in 0.04s. Next: xpt accept 0eae",
"counts": ["1 failed"],
"duration": 0.04,
"run": "20261119T150800-b910",
"created": null,
"failures": [
{
"test": "tests/test_demo.py::test_count",
"when": "call",
"path": "tests/test_demo.py",
"line": 5,
"function": null,
"callers": [],
"source": "expect({\"status\": \"ok\", \"count\": 4}, {\"status\": \"ok\", \"count\": 3})",
"cause": null,
"detail": {"kind": "expect", "observation": {"...": "..."}},
"output": {},
"traceback": "...",
"group": {"id": "0eae", "...": "..."}
}
]
}
- Nothing is truncated. The JSON has every change and the full traceback.
createdis null without--expect-create. With it,createdholdsoutcomesandchangedin the same form asxpt accept --json.- An expect failure adds
groupin the same form asxpt failures --json. - A compared
assertaddschangesandunchanged, with sides namedleftandright.