pytest-sentry
A pytest plugin to send testrun information to Sentry.io
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-sentryuv
uv add pytest-sentrypoetry
poetry add pytest-sentryInstalling 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
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-rerunfailuresA pytest plugin that automatically reruns…
copyleft · top 1,000 on PyPI
sentry-sdkSentry SDK captures and reports Python…
permissive · top 1,000 on PyPI
flakyA pytest plugin that automatically reruns…
permissive · top 5,000 on PyPI
pytest-retrypytest-retry is a pytest plugin that…
permissive · top 5,000 on PyPI
pytest-mergifyA pytest plugin that integrates with Mergify to…
permissive · top 15,000 on PyPI
pytest-repeatA pytest plugin that repeats test execution a…
copyleft · top 5,000 on PyPI
detect-test-pollutionDetects test pollution—failures caused by side…
permissive · top 15,000 on PyPI
ravenRaven is a legacy Python client for Sentry that…
permissive · top 5,000 on PyPI
pytest-instafailA pytest plugin that displays test failures and…
permissive · top 5,000 on PyPI
sentry-cliA command-line tool for interacting with…
permissive · top 15,000 on PyPI