pytest-traceoptix
Opt-in, policy-aware pytest publishing for TraceOptix. Collects test outcomes, step timelines, BDD steps, HTTP call details, and framework-produced evidence (screenshots, videos, traces) without requiring any test-code changes.
Full developer reference: docs/USER_GUIDE.md
Internal design: docs/ARCHITECTURE.md
Not released to PyPI. Install directly from the repository.
Quick start
pip install ./plugins/traceoptix-pytest
export TRACEOPTIX_URL=https://traceoptix.example.com
export TRACEOPTIX_TOKEN=td_...
export TRACEOPTIX_PROJECT=my-project
pytest --traceoptix
No test-code changes needed. Outcomes, durations, markers, and captured output
are published automatically. --junitxml is not required.
Example projects
| Example | Pattern | Steps |
|---|---|---|
| bookshop | Plain pytest, no imports | No |
| bookshop-steps | step() + requests_session() |
Yes — explicit |
| bookshop-bdd | pytest-bdd, no step() |
Yes — Given/When/Then auto-collected |
The bookshop suite targets a fictional API at bookshop.example.com and is
intended as readable documentation, not a runnable fixture.
What's collected
Without any test changes:
- All test outcomes (passed / failed / skipped / errored)
- Duration, captured stdout/stderr/log
- Custom markers as JUnit properties
@p0–@p3priority markers →TestPriorityDeclaration@pytest.mark.issue/@pytest.mark.ticketkeys →TestIssueDeclaration- Evidence from the pytest-playwright output dir (screenshots, videos, traces)
With from pytest_traceoptix import step:
- Named step timeline entries with duration, status, and annotations
With pytest-bdd installed:
- Given/When/Then steps auto-collected as
bdd.steptimeline entries
With from pytest_traceoptix import requests_session:
- HTTP calls inside
step()blocks ashttpchild entries with sanitized cURL
Configuration
| Variable | Description |
|---|---|
TRACEOPTIX_TOKEN |
API token — environment only, never ini/CLI |
TRACEOPTIX_URL |
Server origin (https://…) |
TRACEOPTIX_PROJECT |
Project key |
TRACEOPTIX_BUNDLE_MODE |
always (default) | on-failure | off |
TRACEOPTIX_BUNDLE_DIR |
Directory for local ZIP bundle (default: CWD) |
TRACEOPTIX_ORG |
Organisation slug for run URL output |
TRACEOPTIX_RUN_NAME |
Display name prefix (default: pytest run) |
TRACEOPTIX_ENVIRONMENT |
Deployment environment label |
TRACEOPTIX_BRANCH / TRACEOPTIX_COMMIT_SHA |
Source revision overrides |
TRACEOPTIX_CI_* |
Per-field CI context overrides |
TRACEOPTIX_URL and TRACEOPTIX_PROJECT can also be set via --traceoptix-url,
--traceoptix-project CLI flags, or traceoptix_url / traceoptix_project in
pytest.ini. See docs/USER_GUIDE.md for the full table.
pytest.ini example
[pytest]
traceoptix_url = https://traceoptix.example.com
traceoptix_project = my-project
traceoptix_bundle_mode = on-failure
Local ZIP bundle (PLG-01)
A portable {bundleId}.traceoptix-run.zip is written after every session
(bundle mode always). It contains:
manifest.json Schema v2 — run metadata, priorities, issues
results.xml Merged JUnit XML
steps/ Step timeline JSON per test (full mode only)
evidence/ Screenshots, videos, traces from the playwright output dir
When publication fails, the terminal prints the ZIP path and recovery command:
TraceOptix: recovery bundle: /path/to/{id}.traceoptix-run.zip
(import with: traceoptix import /path/to/{id}.traceoptix-run.zip)
CI auto-detection
GitHub Actions, GitLab CI, Jenkins, CircleCI, Buildkite, Azure Pipelines,
Bitbucket Pipelines, and TeamCity are detected automatically. Override any
field with TRACEOPTIX_CI_PROVIDER, TRACEOPTIX_CI_BUILD_NUMBER, etc.
Development
python3 -m venv .venv
.venv/bin/python -m pip install -e '.[test]'
.venv/bin/ruff check src tests
.venv/bin/ruff format --check src tests
.venv/bin/pytest -q
.venv/bin/python -m build
The integration suite uses an ephemeral localhost HTTP server and real pytest subprocesses. No tenant credentials or databases are required.
References
Metadata
Release files for pytest-traceoptix 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_traceoptix-0.4.0.tar.gz | 43.8 kB | Without provenance | Details for pytest_traceoptix-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_traceoptix-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for pytest_traceoptix-0.4.0-py3-none-any.whl |
Total release size: 73.7 kB
Release files / pytest_traceoptix-0.4.0.tar.gz
| Download URL | pytest_traceoptix-0.4.0.tar.gz |
|---|---|
| Size | 43.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
151ce7d2d4c65095e8d162e1b0a545c5f885ddce9b4a1e554d2c3529e6666e9b
|
|
BLAKE2b-256 checksum How to use checksums |
d7fa1eb12e75456a523fe247b84d8f836ad1e2506c6a392b93e8578e6743af03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / pytest_traceoptix-0.4.0-py3-none-any.whl
| Download URL | pytest_traceoptix-0.4.0-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6688be644038ea7b53c47c4558f3d4fdef75fcc3e5c7db799181c853662f05fa
|
|
BLAKE2b-256 checksum How to use checksums |
a45dac1c359769c90aaa59de66de153f59e30105606db91249a24e8c474f5e56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for pytest-traceoptix 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.