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.

Two other answers exist. Mergify may say the previous attempt of this job already ran every one of these tests and they all passed: the run then executes no test and exits green, and still reports itself so the attempt is visible. Or Mergify may stop the run outright. That happens when several runs of this job report under the same name and run the same tests: Mergify cannot tell which one the current run repeats, and it will not guess which tests to skip. The run then fails, showing Mergify's explanation of what it saw — usually asking you to give each of those runs its own MERGIFY_TEST_JOB_NAME.

Otherwise there is nothing to configure: the plugin uses the token and job identity it already has, and Mergify decides. Every remaining situation — a normal run, a rerun Mergify has no previous results for, an unreachable API, an answer from a newer Mergify this plugin does not understand — runs the full suite, so the feature never costs coverage. It 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

Apache-2.0

Metadata

Release files for pytest-mergify 2026.9.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-mergify 2026.9.7.1
File Size Uploaded
pytest_mergify-2026.9.7.1.tar.gz 118.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pytest-mergify 2026.9.7.1
File
pytest_mergify-2026.9.7.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
pytest_mergify-2026.9.7.1-cp38-abi3-musllinux_1_2_x86_64.whl CPython 3.8 abi3 Linux musl 1.2+ x86-64 Details
pytest_mergify-2026.9.7.1-cp38-abi3-musllinux_1_2_aarch64.whl CPython 3.8 abi3 Linux musl 1.2+ ARM64 Details
pytest_mergify-2026.9.7.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
pytest_mergify-2026.9.7.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
pytest_mergify-2026.9.7.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
pytest_mergify-2026.9.7.1-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 16.5 MB

Release files / pytest_mergify-2026.9.7.1.tar.gz

Download URL pytest_mergify-2026.9.7.1.tar.gz
Size 118.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8c49310fc22d81c72829b665e2b49678415e3816a6736515fcf66bf1eddc94fd
BLAKE2b-256 checksum
How to use checksums
9f529438e99aca297bdb07d4ff84e2a6c2ca3ae3e66344b82726707bbcc3cd11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pytest_mergify-2026.9.7.1-cp38-abi3-win_amd64.whl

Download URL pytest_mergify-2026.9.7.1-cp38-abi3-win_amd64.whl
Size 2.3 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0b7166b8c7b7766aa69dda0834229f9a8f621b1e303b990ffab8c5d54e3ed21d
BLAKE2b-256 checksum
How to use checksums
ce1442edfa5d6ed4518ca4540c2235aac45be0a3a344452001cbe5ffca5b9913
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pytest_mergify-2026.9.7.1-cp38-abi3-musllinux_1_2_x86_64.whl

Download URL pytest_mergify-2026.9.7.1-cp38-abi3-musllinux_1_2_x86_64.whl
Size 2.6 MB
Tags CPython 3.8 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
d19d69ddc9e29a9f946fe388d1029990d7e828b9a882604f032d8f1e7baf75bb
BLAKE2b-256 checksum
How to use checksums
dce73ee296f37058fefea60de347866c9a8a997440250c2859f57b987ad7769f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pytest_mergify-2026.9.7.1-cp38-abi3-musllinux_1_2_aarch64.whl

Download URL pytest_mergify-2026.9.7.1-cp38-abi3-musllinux_1_2_aarch64.whl
Size 2.4 MB
Tags CPython 3.8 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
12637c9d27c942fa64ecace353250559392a7cb33c2d1e459278675a8fcc773d
BLAKE2b-256 checksum
How to use checksums
30c1a3e4bc085e2086cbc28a1442374ee8e1bbf205ee8dddcaea3826df29a599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pytest_mergify-2026.9.7.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pytest_mergify-2026.9.7.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.4 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
98f2baaa9fdaadc352fbb84538dd7c65835ffe4694e6609e3e3f81ad8f6c4d87
BLAKE2b-256 checksum
How to use checksums
02e37f54f852e2373c848139e057d645efb63ba89baa95e3b5c6248a86ab8143
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pytest_mergify-2026.9.7.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pytest_mergify-2026.9.7.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.3 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5f8aa65faa5ff643353c81c8894c0020a68f6531e29abb4dbbc5354a9848635f
BLAKE2b-256 checksum
How to use checksums
17fd36d4a5154d937fd02eaed8794bbe4d912f5c8ab75015657e2c241e325061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pytest_mergify-2026.9.7.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL pytest_mergify-2026.9.7.1-cp38-abi3-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
475880080e44193520620f0912da74e8a3ac10ecd42f6978a5601db8c6433b41
BLAKE2b-256 checksum
How to use checksums
24b9432fe014df7478a80a2d9028e2058fe8600a308615c002957c311d4d83aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pytest_mergify-2026.9.7.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL pytest_mergify-2026.9.7.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 2.2 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
09154f74aab4e3adb70db202f079c0a555bbef74f2a407407779d23aad80086e
BLAKE2b-256 checksum
How to use checksums
a221ad6eddac467713039b579ef8adaf606963397b1bd1448ecab1b60c311834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.7.1 This release

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page