pytest-mergify
Pytest plugin for Mergify
What it is and what it does
pytest-mergify is a pytest plugin that connects your test runs to Mergify's Test Insights platform via OpenTelemetry tracing. It automatically detects flaky tests by intelligently rerunning them within budget constraints, quarantines failing tests to prevent CI blockage, and can selectively run only previously-failing tests when Mergify's merge queue reruns a job—reducing redundant test execution. The plugin requires pytest >= 6.0.0 and pytest-timeout, auto-discovers without manual registration, and activates when running in CI (detected via the CI environment variable) or when explicitly enabled via PYTEST_MERGIFY_ENABLE=true. Configuration is minimal: set the MERGIFY_TOKEN environment variable with your API token, and optionally customize the API endpoint or debug output.
Use it for:
- Detect flaky tests in CI pipelines by automatically rerunning tests with budget constraints to identify intermittent failures.
- Reduce merge queue wait time by running only tests that failed in the previous attempt when Mergify reruns a job.
- Quarantine failing tests to prevent them from blocking CI while still capturing failure data for later analysis.
- Trace test execution with OpenTelemetry spans sent to Mergify for centralized test insights and performance monitoring.
- Opt out of test selection per-run by setting MERGIFY_TEST_SELECTION_DISABLE=true while keeping tracing and flaky detection active.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that integrates with Mergify to trace tests via OpenTelemetry, detect flaky tests, quarantine failures, and selectively run only previously-failing tests in merge queue reruns.
Yes, if you use Mergify and want to reduce CI time and improve test reliability. The plugin is actively maintained, has no known vulnerabilities, uses a permissive license, and requires only pytest and pytest-timeout. Install friction is medium due to compiled wheels, but the stable ABI (cp38-abi3) covers modern Python versions. The main gotcha is that MERGIFY_TOKEN must be set and test selection requires organization opt-in on Mergify's side, but these are configuration rather than blocker issues.
Install
pytest-mergify on PyPI
pip
pip install pytest-mergifyuv
uv add pytest-mergifypoetry
poetry add pytest-mergifyInstalling pytest-mergify
Before you install
Medium install friction due to compiled wheels across multiple platforms (cp38-abi3 stable ABI). Active maintenance with a release 9 days old. Requires pytest and pytest-timeout as runtime dependencies.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install pytest-mergify
# Set required environment variable
export MERGIFY_TOKEN=your_token
# Run pytest normally; plugin auto-discovers
pytest
Requires MERGIFY_TOKEN environment variable to be set; plugin activates automatically in CI or when PYTEST_MERGIFY_ENABLE=true is set.
Verify before relying
- Whether test selection feature requires explicit organization opt-in on Mergify's side beyond environment setup.
- Performance impact of OpenTelemetry tracing on large test suites.
- Compatibility with pytest fixtures and parametrization in flaky detection reruns.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — pytest, pytest-timeout |
| Maintenance | actively maintained — 9 days since the last release |
| First released | |
| Downloads | 76,654/month — #14,603 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_mergify-2026.8.5.3-cp38-abi3-macosx_10_12_x86_64.whl; pytest_mergify-2026.8.5.3-cp38-abi3-macosx_11_0_arm64.whl; pytest_mergify-2026.8.5.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; pytest_mergify-2026.8.5.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; pytest_mergify-2026.8.5.3-cp38-abi3-musllinux_1_2_aarch64.whl; pytest_mergify-2026.8.5.3-cp38-abi3-musllinux_1_2_x86_64.whl; pytest_mergify-2026.8.5.3-cp38-abi3-win_amd64.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
mergify-cliMergify CLI is a command-line tool for managing…
permissive · top 15,000 on PyPI
pytest-retrypytest-retry is a pytest plugin that…
permissive · top 5,000 on PyPI
flakyA pytest plugin that automatically reruns…
permissive · top 5,000 on PyPI
pytest-rerunfailuresA pytest plugin that automatically reruns…
copyleft · top 1,000 on PyPI
pytest-sentryA pytest plugin that sends test failure and…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-celeryAdds distributed tracing and observability to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-remouladeAdds distributed tracing instrumentation for…
permissive · top 5,000 on PyPI
pytest-opentelemetryA pytest plugin that instruments test runs with…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-pikaAdds distributed tracing to pika (RabbitMQ…
permissive · top 5,000 on PyPI
azure-monitor-opentelemetry-exporterExports OpenTelemetry traces, metrics, and logs…
permissive · top 1,000 on PyPI