Metadata-Version: 2.4
Name: respan-instrumentation-pytest
Version: 0.1.0
Summary: Respan tracing plugin for Pytest sessions and tests
License: Apache 2.0
Author: Respan
Author-email: team@respan.ai
Requires-Python: >=3.11,<3.14
Classifier: Framework :: Pytest
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: opentelemetry-semantic-conventions-ai (>=0.4.1)
Requires-Dist: pytest (>=7.4.0,<10.0.0)
Requires-Dist: respan-sdk (>=2.6.1)
Requires-Dist: respan-tracing (>=2.17.0,<3.0.0)
Description-Content-Type: text/markdown

# respan-instrumentation-pytest

An installable Pytest plugin that emits one canonical Respan workflow span for each test session and one task span for every test protocol. The test span remains current across setup, synchronous or asynchronous execution, and teardown, so application spans created by a test are nested beneath the correct test.

The plugin records pass, skip, xfail, setup failure, assertion failure, teardown failure, phase duration, parametrization, markers, and fixture names. Failures include OpenTelemetry error status plus backend-visible `status_code` and `error.message` fields.

## Install and enable

```bash
pip install respan-ai respan-instrumentation-pytest
pytest --respan-tracing
```

Pytest discovers the package through its `pytest11` entry point. It remains opt-in after installation so a globally installed plugin does not unexpectedly export every test run. Enable it in CI with:

```bash
RESPAN_PYTEST_ENABLED=true pytest
```

The usual `RESPAN_API_KEY` and optional `RESPAN_BASE_URL` variables configure export. Configuration can also live in `pytest.ini`:

```ini
[pytest]
respan_tracing = true
respan_capture_content = true
respan_workflow_name = checkout_integration_tests
```

Equivalent environment variables are `RESPAN_PYTEST_ENABLED`, `RESPAN_PYTEST_CAPTURE_CONTENT`, and `RESPAN_PYTEST_WORKFLOW_NAME`.

## Content capture

By default, test parameters, fixture names, markers, and failure text are captured. Disable sensitive values with:

```bash
pytest --respan-tracing --no-respan-capture-content
```

With capture disabled, node IDs, outcomes, phase durations, and exception types remain visible while parameter values and failure messages are omitted. Fixture return values are never recorded. Each xdist worker creates its own session span with worker metadata. The lifecycle is idempotent.

