Package Overview
testrelic-pytest is published on PyPI (current version 0.3.1).
Terminal
pip install testrelic-pytest
The plugin model
The package registers itself through a pytest11 entry point. There is nothing to import and no conftest.py wiring — once the package is installed in the same environment as pytest, the plugin is active on the next pytest run.
Requirements: Python >=3.9, pytest>=7.0, httpx>=0.27.
Flags and environment variables
Every pytest option has a matching environment variable. CLI flags take precedence over environment variables.
| Flag | Env var | Default | Purpose |
|---|---|---|---|
--testrelic-pytest-disable | TESTRELIC_DISABLE=1 | off | Force-disable the plugin |
--testrelic-pytest-api-key VALUE | TESTRELIC_API_KEY | — | API key from the dashboard |
--testrelic-pytest-endpoint URL | TESTRELIC_CLOUD_ENDPOINT | https://platform.testrelic.ai/api/v1 | Cloud base URL |
--testrelic-pytest-upload-strategy {batch,realtime,both,none} | TESTRELIC_UPLOAD_STRATEGY | batch | When to send results |
--testrelic-pytest-quiet | TESTRELIC_QUIET=1 | off | Suppress banner output |
--testrelic-pytest-run-type {smoke,regression,nightly,ci} | TESTRELIC_RUN_TYPE | — | Dashboard bucket |
--testrelic-pytest-project-name NAME | TESTRELIC_PROJECT_NAME | git remote or pyproject name | Stable project identity |
--testrelic-pytest-artifact-threshold-kb N | — | 32 | Output beyond N KB truncated inline |
--testrelic-pytest-output PATH | — | — | Optional JSON dump for debugging |
--testrelic-pytest-no-autodetect | TESTRELIC_NO_AUTODETECT=1 | off | Disable httpx/requests HTTP auto-detection |
--testrelic-pytest-no-capture-bodies | TESTRELIC_NO_CAPTURE_BODIES=1 | off | Don't capture request/response bodies |
--testrelic-pytest-no-capture-headers | TESTRELIC_NO_CAPTURE_HEADERS=1 | off | Don't capture request/response headers |
--testrelic-pytest-no-capture-assertions | TESTRELIC_NO_CAPTURE_ASSERTIONS=1 | off | Don't capture pytest assert statements |
The cloud request timeout is set with TESTRELIC_CLOUD_TIMEOUT (milliseconds).
CLI commands
Installing the package also installs a testrelic-pytest CLI:
| Command | Purpose |
|---|---|
testrelic-pytest version | Print the installed version |
testrelic-pytest drain [--queue-dir PATH] | Retry queued failed uploads |
testrelic-pytest status [--queue-dir PATH] | Show the pending replay count |
The offline queue directory defaults to .testrelic/queue/ (project-local).