pytest-fail-slow
Fail tests that take too long to run
What it is and what it does
pytest-fail-slow is a pytest plugin that enforces test duration limits by marking tests as failed when they exceed a specified time threshold. It operates in two modes: you can apply a `fail_slow` marker to individual tests with a duration cutoff, or pass a `--fail-slow DURATION` option to pytest to apply a global cutoff to all unmarked tests. The plugin also supports a `fail_slow_setup` marker to fail tests if their fixture setup stages exceed a duration limit. Tests run to completion even when they exceed the threshold—if you want to stop them early, the plugin documentation recommends pytest-timeout instead.
The plugin accepts durations in multiple units (seconds, milliseconds, hours, etc.) and supports conditional enabling via an `enabled` keyword argument, allowing you to apply different thresholds or disable checks based on environment variables or pytest configuration. It is actively maintained, supports Python 3.8 through 3.12 on both CPython and PyPy, and includes type hints.
Use it for:
- Enforce maximum test duration in CI pipelines to catch performance regressions before they reach production.
- Mark tests that are intentionally slow (e.g., integration tests) with a higher threshold to distinguish them from unit tests.
- Conditionally fail slow tests only in CI environments while allowing longer runs during local development.
- Detect fixture setup overhead by monitoring setup duration separately from test execution time.
- Apply a blanket duration limit across all tests via command-line option without modifying test code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that marks tests as failed if they exceed a specified duration threshold, either via per-test markers or a global command-line option.
Yes. The plugin is lightweight, actively maintained, permissively licensed, and solves a concrete problem—catching performance regressions in test suites. Install it if you need to enforce test duration limits in CI or detect slow tests without stopping them early.
Install
pytest-fail-slow on PyPI
pip
pip install pytest-fail-slowuv
uv add pytest-fail-slowpoetry
poetry add pytest-fail-slowInstalling pytest-fail-slow
Before you install
Low friction installation with no compiled dependencies. The package is actively maintained, with recent commits and a stable release cadence since its initial release in 2021.
License in practice
Licensed under MIT (permissive), so you can use it freely in commercial and private projects without restriction or obligation to share modifications.
Quickstart
pip install pytest-fail-slow
import pytest
@pytest.mark.fail_slow("5s")
def test_something():
pass
Requires Python 3.8 or higher and pytest 7.0 or higher.
Verify before relying
- Whether the plugin integrates cleanly with other pytest plugins in typical test suites.
- Performance overhead of duration tracking across large test suites.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — pluggy, pytest |
| Maintenance | actively maintained — 804 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 176,356/month — #10,245 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_fail_slow-0.6.0-py3-none-any.whl
Keywords: pytest, slow tests, timeout
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
pytest-integrationA pytest plugin that organizes tests into unit,…
permissive · top 15,000 on PyPI
pytest-timeoutAborts pytest tests that exceed a specified…
permissive · top 1,000 on PyPI
pytest-retrypytest-retry is a pytest plugin that…
permissive · top 5,000 on PyPI
pytest-raisesProvides pytest markers (@pytest.mark.raises…
unclear · top 15,000 on PyPI
pytest-timeoutsA pytest plugin that enforces separate timeout…
permissive · top 5,000 on PyPI
pytest-durationsA pytest plugin that measures and reports…
permissive · top 5,000 on PyPI
pytest-orderA pytest plugin that lets you control the order…
permissive · top 5,000 on PyPI
pytest-tornadoA pytest plugin that provides fixtures and…
permissive · top 15,000 on PyPI
coverage-thresholdValidates Python code coverage against…
permissive · top 15,000 on PyPI
pytest-loopA pytest plugin that repeats tests a fixed…
copyleft · top 15,000 on PyPI