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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pytest_mergify-2026.8.4.1-cp38-abi3-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.8+Windows x86-64

pytest_mergify-2026.8.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

pytest_mergify-2026.8.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

pytest_mergify-2026.8.4.1-cp38-abi3-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

pytest_mergify-2026.8.4.1-cp38-abi3-macosx_10_12_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file pytest_mergify-2026.8.4.1-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pytest_mergify-2026.8.4.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5f37bf6809193bba1c566b8131ed4a8b9e97c16813a7f5101eb0787af837cb48
MD5 d57f879c972010403a62053929bb99b8
BLAKE2b-256 4df37d61a91a4020b99c25f020f92b9e7e249eb13909c116eb324fe22f57c7d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.8.4.1-cp38-abi3-win_amd64.whl:

Publisher: release-pytest-mergify.yml on Mergifyio/mergify-ci-integrations

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.8.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytest_mergify-2026.8.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c2d573c9d9f7dd4fc8630087c982ae5c56afbac22cf891368a91b00f1e2aa627
MD5 954285ae6e677bbd783d459bb8b1da2d
BLAKE2b-256 1f4af77f563460400993aeb5c072c76ac7b361b6cd5c4de865b59f79b4077ac2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.8.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pytest-mergify.yml on Mergifyio/mergify-ci-integrations

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.8.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pytest_mergify-2026.8.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f7aba14a97fb5109d9a7793466f77a0f99285d68da6dc8a121f666ee6aabe5d5
MD5 7dd137883915bc7dc043cd551147fbd3
BLAKE2b-256 e0e806397a3fd7e22e863f3eee21d10516b2d3e825d14e663cfeb0894f1d5239

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.8.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-pytest-mergify.yml on Mergifyio/mergify-ci-integrations

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.8.4.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytest_mergify-2026.8.4.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46ccee3c0e65a3a71259c8830b90d5626802faf54eb370b6f2828269f5451998
MD5 84578d860bf3130ace21f455f20c369a
BLAKE2b-256 d41ac5de4212be175e93f83a471f411f3f4ef5cf740f9432aeadae9f030b85ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.8.4.1-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release-pytest-mergify.yml on Mergifyio/mergify-ci-integrations

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.8.4.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pytest_mergify-2026.8.4.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 06ef2c0f90acd1104b5f761f0c4aa9aa959b074f8b9ff830c518f90862c382a7
MD5 c4f324d7ca46b383229f4d35fa74a97c
BLAKE2b-256 2e86588cd40723bb4d1dade6a5cc13153e5e8944fec11f5e2e94547fbd964c75

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.8.4.1-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: release-pytest-mergify.yml on Mergifyio/mergify-ci-integrations

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