pytest-mergify

raw JSON →
2026.4.7.1 verified Fri May 01 auth: no python

A pytest plugin that reports test results to Mergify for merge queue optimization. Current version 2026.4.7.1, requires Python >=3.8. Released frequently (almost daily) with version numbers based on date.

pip install pytest-mergify
error ModuleNotFoundError: No module named 'pytest_mergify'
cause The package is installed but not imported correctly; it's a pytest plugin, not a direct import.
fix
Use pytest --mergify instead of importing the module.
error TypeError: __init__() got an unexpected keyword argument 'token'
cause Using old API with `--mergify-token` where plugin expects env var.
fix
Remove the CLI argument and set MERGIFY_TOKEN environment variable.
error pytest: error: unrecognized arguments: --mergify
cause The plugin is not installed or not registered in pytest.
fix
Run pip install pytest-mergify and ensure it's in the environment.
gotcha The MERGIFY_TOKEN environment variable is required for the plugin to work. Without it, tests will run but results won't be reported.
fix Set MERGIFY_TOKEN before running pytest.
deprecated Older versions used `--mergify-token` CLI argument; newer versions prefer environment variable.
fix Use MERGIFY_TOKEN env var instead of CLI argument.
breaking Version 2025.10.0 changed the required Python version from 3.7 to 3.8.
fix Ensure Python >= 3.8.
gotcha The plugin only sends results on test session finish; it may fail silently if network is unavailable.
fix Check network connectivity and verify API endpoint.

Write a simple test, then run: `pytest --mergify` or set MERGIFY_TOKEN env var.

import pytest

def test_example():
    assert 1 + 1 == 2