Skip to main content

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–@p3 priority markers → TestPriorityDeclaration
  • @pytest.mark.issue / @pytest.mark.ticket keys → 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.step timeline entries

With from pytest_traceoptix import requests_session:

  • HTTP calls inside step() blocks as http child 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)

Source distribution for pytest-traceoptix 0.4.0
File Size Uploaded
pytest_traceoptix-0.4.0.tar.gz 43.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-traceoptix 0.4.0
File Interpreter ABI Platform
pytest_traceoptix-0.4.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page