skillfed

pytest-sentry

A pytest plugin to send testrun information to Sentry.io

pytest-sentry v0.5.1 80.4K downloads/30d#14,294 on PyPI55
Permissive license BSD-2-Clause AGING released

What it is and what it does

pytest-sentry is a pytest plugin that integrates with Sentry to track and aggregate test run data. It is designed to work alongside pytest-rerunfailures to capture flaky test failures—tests that fail intermittently but pass on retry—and report them to Sentry without breaking the CI build. By default, only flaky tests are reported; consistently failing tests are not sent, and consistently passing tests generate no errors.

The plugin also sends performance data to Sentry by default, tracking fixture setup times and test execution times as separate transactions within a trace. This lets you identify slow fixtures and large tests. Configuration is entirely environment-variable driven (PYTEST_SENTRY_DSN, PYTEST_SENTRY_TRACES_SAMPLE_RATE, etc.), with optional per-test overrides via pytest markers. The plugin maintains strict isolation between its own Sentry client and any Sentry SDK usage in the code being tested, to avoid quota waste from expected errors in the application.

Use it for:

  • Track flaky tests in CI that are hidden by automatic retry plugins, keeping visibility without breaking builds.
  • Identify slow test fixtures and test functions by sending performance transactions to Sentry.
  • Report all test failures on specific branches (e.g., main) by setting PYTEST_SENTRY_ALWAYS_REPORT=1.
  • Correlate test failures with CI metadata (branch, commit, environment) using Sentry's tagging system.
  • Disable Sentry reporting for specific tests using pytest markers when you want to exclude certain test runs.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that sends test failure and performance data to Sentry, with special handling for flaky tests detected via pytest-rerunfailures.

Yes, if you use pytest-rerunfailures and want visibility into flaky test patterns without cluttering your CI status. The low install friction and permissive license make adoption straightforward. However, note that the package is aging (409 days since last release); verify compatibility with your current pytest and sentry-sdk versions before relying on it in production CI.

Install

pytest-sentry on PyPI

pip

pip install pytest-sentry

uv

uv add pytest-sentry

poetry

poetry add pytest-sentry

Installing pytest-sentry

Before you install

Low friction install with three runtime dependencies (pytest, sentry-sdk, wrapt). Maintenance status is aging—last release was 409 days ago, though the repository remains active and not archived.

License in practice

BSD-2-Clause is permissive; you can use this in commercial or proprietary projects with minimal restrictions, provided you include the license text.

Quickstart

pip install pytest-sentry

export PYTEST_SENTRY_DSN="https://xx@xxx.ingest.sentry.io/xxx"
export PYTEST_SENTRY_TRACES_SAMPLE_RATE=1
pytest --reruns=5

Requires pytest-rerunfailures plugin to be installed and enabled for flaky test detection to work as intended.

Verify before relying

  • Whether the aging maintenance status (409 days since last release) affects compatibility with recent pytest or sentry-sdk versions.
  • Performance overhead of transaction reporting in large test suites and whether sampling rates are sufficient to manage quota.

Package facts

License BSD-2-Clause (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 3 — pytest, sentry-sdk, wrapt
Maintenance aging — 409 days since the last release
Last repo commit
First released
Downloads 80,423/month — #14,294 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_sentry-0.5.1-py3-none-any.whl

License :: OSI Approved :: BSD License

Tags

pytest sentry integrationflaky test trackingtest failure reportingpytest performance monitoringsentry test pluginci test aggregationpytest error reporting
test-monitoringci-integrationflaky-test-tracking

More Testing packages