Skip to main content

pytest-mergify

Pytest plugin for Mergify Test Insights.

More information at https://mergify.com

Features

  • Test tracing — Sends OpenTelemetry traces for every test to Mergify's API
  • Flaky test detection — Intelligently reruns tests to detect flakiness with budget constraints
  • Test quarantine — Quarantines failing tests so they don't block CI
  • Test selection — Runs only the previously-failing tests when Mergify's merge queue reruns a job

Installation

Install the package alongside pytest (>= 6.0.0):

pip install pytest-mergify

The plugin is auto-discovered by pytest — no manual registration required.

Configuration

Set the MERGIFY_TOKEN environment variable with your Mergify API token.

The plugin activates automatically when running in CI (detected via the CI environment variable). To enable outside CI, set PYTEST_MERGIFY_ENABLE=true.

Environment Variables

Variable Description Default
MERGIFY_TOKEN Mergify API authentication token (required)
MERGIFY_API_URL Mergify API endpoint https://api.mergify.com
PYTEST_MERGIFY_ENABLE Force-enable outside CI false
PYTEST_MERGIFY_DEBUG Print spans to console false
MERGIFY_TRACEPARENT W3C distributed trace context
MERGIFY_TEST_JOB_NAME Mergify test job name
MERGIFY_TEST_SELECTION_DISABLE Opt out of test selection (see below) false

For detailed documentation, see the official guide.

Test selection

When Mergify's merge queue reruns a job — a retry, or a step of a batch bisection — only the tests that failed on the previous attempt are informative. The plugin asks Mergify whether the current run is such a rerun and, if so, runs only those tests; the rest are reported as deselected.

Nothing to configure: the plugin uses the token and job identity it already has, and Mergify decides. Any other situation — a normal run, a rerun Mergify has no previous results for, an unreachable API — runs the full suite, so the feature can only remove work, never coverage. The feature is also enabled per organization on Mergify's side, so it stays inactive until your organization is opted in.

Set MERGIFY_TEST_SELECTION_DISABLE=true in your CI to opt out: the plugin then always runs the full suite and never queries the endpoint. It is scoped to this feature only — test tracing, flaky detection and quarantine keep working (unset MERGIFY_TOKEN to turn the plugin off entirely).

Development

Prerequisites

  • Python >= 3.8
  • uv

Setup

uv sync

Running Tests

uv run poe test

Linting

uv run poe linters

License

GPL-3.0-only

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_mergify-2026.7.29.1.tar.gz (108.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_mergify-2026.7.29.1-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_mergify-2026.7.29.1.tar.gz.

File metadata

  • Download URL: pytest_mergify-2026.7.29.1.tar.gz
  • Upload date:
  • Size: 108.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pytest_mergify-2026.7.29.1.tar.gz
Algorithm Hash digest
SHA256 e5e152d239d14e6b5e70b7aad23a2fcba841ee07bae425aee5fccaf434148471
MD5 a0bfa51fb28e1d5588aa5d7e69f7462c
BLAKE2b-256 03acaf96ca80f6c4ede2bd32113f24f9b4bef7d449e792a359dc952b7708ea42

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.7.29.1.tar.gz:

Publisher: release.yml on Mergifyio/pytest-mergify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_mergify-2026.7.29.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_mergify-2026.7.29.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92d0463d560f130fea2d16155e4776ab366ed2a142b4d7315a79274960888833
MD5 77dc2a16a6428d73e862bb0f5669fed1
BLAKE2b-256 b134209e594e43ee8d0fb5d1fc4eacc3f2d056ece56265a45d8301d3b95ab416

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.7.29.1-py3-none-any.whl:

Publisher: release.yml on Mergifyio/pytest-mergify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page