skillfed

pytest-fail-slow

Fail tests that take too long to run

pytest-fail-slow v0.6.0 176.4K downloads/30d#10,245 on PyPI11
Permissive license Active released

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-slow

uv

uv add pytest-fail-slow

poetry

poetry add pytest-fail-slow

Installing 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

Environment :: PluginsFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: TestingTyping :: Typed

Tags

pytest slow test detectionfail tests that run too longpytest duration thresholdtest performance timeout markerpytest test speed enforcementcatch slow running testspytest performance regression
pytest-pluginperformance-testingci-enforcement

More Testing packages