--- id: pytest-fail-slow version: "0.6.0" license: unclear license_treatment: permissive maintenance: active --- # pytest-fail-slow — Fail tests that take too long to run License: permissive · Maintenance: active · Downloads: 176.4K/mo ## 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 above — 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 pip install pytest-fail-slow uv add pytest-fail-slow 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_current - Install friction: low - Maintenance: active - Downloads: 176.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest slow test detection, fail tests that run too long, pytest duration threshold, test performance timeout marker, pytest test speed enforcement, catch slow running tests, pytest performance regression, pytest-plugin, performance-testing, ci-enforcement [View on SkillFed](https://skillfed.io/packages/pytest-fail-slow) · [View on PyPI](https://pypi.org/project/pytest-fail-slow/)