Configuration

Complete reference for every testrelic-pytest flag and environment variable: upload strategy, run-type, capture toggles, and metadata.

Every behavior is controlled by a pytest flag with a matching environment variable. CLI flags take precedence over environment variables.

Full reference

FlagEnv varDefaultPurpose
--testrelic-pytest-disableTESTRELIC_DISABLE=1offForce-disable the plugin
--testrelic-pytest-api-key VALUETESTRELIC_API_KEY—API key from the dashboard
--testrelic-pytest-endpoint URLTESTRELIC_CLOUD_ENDPOINThttps://platform.testrelic.ai/api/v1Cloud base URL
--testrelic-pytest-upload-strategy {batch,realtime,both,none}TESTRELIC_UPLOAD_STRATEGYbatchWhen to send results
--testrelic-pytest-quietTESTRELIC_QUIET=1offSuppress banner output
--testrelic-pytest-run-type {smoke,regression,nightly,ci}TESTRELIC_RUN_TYPE—Dashboard bucket
--testrelic-pytest-project-name NAMETESTRELIC_PROJECT_NAMEgit remote or pyproject nameStable project identity
--testrelic-pytest-artifact-threshold-kb N—32Output beyond N KB truncated inline
--testrelic-pytest-output PATH——Optional JSON dump for debugging
--testrelic-pytest-no-autodetectTESTRELIC_NO_AUTODETECT=1offDisable httpx/requests/aiohttp HTTP auto-detection
--testrelic-pytest-no-capture-bodiesTESTRELIC_NO_CAPTURE_BODIES=1offDon't capture request/response bodies
--testrelic-pytest-no-capture-headersTESTRELIC_NO_CAPTURE_HEADERS=1offDon't capture request/response headers
--testrelic-pytest-no-capture-assertionsTESTRELIC_NO_CAPTURE_ASSERTIONS=1offDon't capture pytest assert statements
--testrelic-pytest-no-enrichTESTRELIC_NO_ENRICH=1offDisable report enrichment
--testrelic-pytest-allure-dir DIRTESTRELIC_ALLURE_DIRfrom --alluredirAllure results directory to enrich from
--testrelic-pytest-junit-xml FILETESTRELIC_JUNIT_XMLfrom --junitxmlJUnit XML report to enrich from

The cloud request timeout is set with TESTRELIC_CLOUD_TIMEOUT (milliseconds, default 30000).

Config file

Settings can also live in .testrelic/testrelic-config.json; the plugin looks for it in the pytest root directory and its parents. Precedence is CLI flags, then environment variables, then the config file, then defaults. Cloud settings go under a cloud block (or at the top level), and a string value starting with $ is read from that environment variable:

.testrelic/testrelic-config.json
{
  "cloud": {
    "apiKey": "$TESTRELIC_API_KEY",
    "upload": "batch",
    "runType": "ci",
    "projectName": "checkout-service"
  },
  "metadata": { "team": "payments" }
}

Top-level keys: quiet, outputPath, metadata (extra key/value pairs attached to the run), enrichFromReports, allureDir, junitXml. Cloud keys: apiKey, endpoint, upload, timeout, artifactThresholdKb, queueDirectory, projectName, runType. With no API key from any source, the plugin does not upload.

Upload strategy

--testrelic-pytest-upload-strategy decides when results are transmitted:

ValueBehavior
batchSend results at the end of the run (default)
realtimeSend results as tests complete
bothSend both in realtime and as a batch
noneDon't upload

Run-type buckets

--testrelic-pytest-run-type groups runs on the dashboard. Valid buckets: smoke, regression, nightly, ci. When unset, the run is not assigned a bucket.

Capture toggles

By default the plugin captures HTTP request/response bodies, headers, cookies, and pytest assertions. Bodies are truncated at 32 KB, sensitive headers and cookie values are masked, and streamed bodies are never consumed. Each capture can be disabled:

ToggleEffect
--testrelic-pytest-no-autodetect (TESTRELIC_NO_AUTODETECT=1)Disable httpx/requests/aiohttp HTTP auto-detection
--testrelic-pytest-no-capture-bodies (TESTRELIC_NO_CAPTURE_BODIES=1)Don't capture request/response bodies
--testrelic-pytest-no-capture-headers (TESTRELIC_NO_CAPTURE_HEADERS=1)Don't capture request/response headers
--testrelic-pytest-no-capture-assertions (TESTRELIC_NO_CAPTURE_ASSERTIONS=1)Don't capture pytest assert statements

Captured headers are masked for sensitive values, and bodies and captured streams are truncated.

Artifact threshold

--testrelic-pytest-artifact-threshold-kb (default 32) sets the size beyond which captured stdout/stderr/caplog output is truncated inline (per stream). HTTP request/response bodies have their own fixed 32 KB limit.

Git and CI metadata

The plugin auto-detects CI metadata for GitHub Actions, GitLab CI, Jenkins, CircleCI, and Bitbucket Pipelines, plus the git branch, commit, and author. When .git is unavailable, it falls back to CI environment variables.

Project identity

--testrelic-pytest-project-name (env TESTRELIC_PROJECT_NAME) sets a stable project identity. When unset, the plugin derives it from the git remote or the pyproject name.

Test-type markers

HTTP auto-detection sets a test's type for you, but you can also set it explicitly with markers. Use the dedicated marker:

tests/test_orders.py
import pytest

@pytest.mark.testrelic_type("api")
def test_create_order():
    ...

Or apply a bare type marker — e2e, api, unit, or mobile:

tests/test_checkout.py
import pytest

@pytest.mark.e2e
def test_checkout_flow():
    ...

An explicit marker takes precedence over auto-detection. The plugin also rolls the per-test types up into a single run-level test-type, so the run is bucketed correctly on the dashboard.

Was this page helpful?

On this page