Skip to main content

PyPI version Python Development Status Maintenance PyPI License


💡 pytest-max-fail-streak

A pytest plugin that stops the run after N consecutive failing tests.

A burst of consecutive failures usually means the environment is down — a device is unreachable, a service doesn't respond — and every remaining test would fail for the same reason. Instead of waiting for all of them, stop early and get a clear signal.


📦 Installation

uv add pytest-max-fail-streak

🚀 Features

  • ✅ Consecutive, not total — complements pytest's --maxfail, which counts failures in total
  • ✅ Catches a broken environment — setup and teardown errors count, so an unreachable device stops the run
  • ✅ A real stop — the run ends like --maxfail ends it; remaining tests aren't run or reported as skipped
  • ✅ Fair counting — skipped and xfailed tests are neutral, and each test counts once
  • ✅ Zero footprint without the flag — nothing is registered, no hook runs

🛠️ How to Use

pytest --maxfail-streak=5

The run stops after 5 failing tests in a row, with exit code 1 and a summary line:

!!!!!!!!!! stopping after 5 consecutive failures (--maxfail-streak=5) !!!!!!!!!!

⚙️ How the Streak Is Counted

Each test is judged once, after its teardown:

Test result Effect on the streak
Failed in setup, call or teardown (failure or error) +1
Passed Reset to 0
Skipped or xfailed Unchanged

When the streak reaches N, the run stops after the current test.

N must be a positive integer; any other value is a usage error (exit code 4).


🤔 --maxfail-streak vs. --maxfail

--maxfail=N --maxfail-streak=N
Counts Failures in total Failures in a row
Typical signal "Too much is broken" "The environment is down"
A passing test in between Doesn't matter Resets the count

Both can be used together; whichever is reached first stops the run.


▶️ Usage Examples

Enable in pytest.ini for CI

[pytest]
addopts =
    --maxfail-streak=5

⚠️ Notes

  • With pytest-xdist, results arrive from several workers interleaved, so "consecutive" follows the order they arrive in, not the order of the test files.

🔁 Migrating from pytest-plugins

This plugin was previously max_fail_streak in pytest-plugins. Both register the --maxfail-streak option, so don't install them together until you're on a pytest-plugins release without it. Changes when migrating:

  • The run now stops instead of skipping the remaining tests.
  • Setup and teardown errors now count; skipped tests no longer reset the streak.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-addition
  3. Make your changes
  4. Commit your changes: git commit -m 'Add my addition'
  5. Push to the branch: git push origin feature/my-addition
  6. Open a Pull Request

Additions that promote clean, productive, and maintainable development are always welcome.


📄 License

MIT License — see LICENSE for details.


🙏 Thanks

Thanks for exploring this repository!
Happy coding!

GitHub   PyPI   Blog   LinkedIn

Metadata

Release files for pytest-max-fail-streak 1.0.0

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-max-fail-streak 1.0.0
File Size Uploaded Provenance Actions
pytest_max_fail_streak-1.0.0.tar.gz 5.4 kB Without provenance Details for pytest_max_fail_streak-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-max-fail-streak 1.0.0
File Interpreter ABI Platform Actions
pytest_max_fail_streak-1.0.0-py3-none-any.whl Python 3 none any Details for pytest_max_fail_streak-1.0.0-py3-none-any.whl

Total release size: 11.5 kB

Release files / pytest_max_fail_streak-1.0.0.tar.gz

Download URL pytest_max_fail_streak-1.0.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
af193e4703abbe2b33d42426e5fa2b6a7bb60a181cda2b5869188d6e092b211e
BLAKE2b-256 checksum
How to use checksums
7e85bb7fd846fd8986dfb1f8035d670806015e13ecb79b94663da4de74b65134
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pytest_max_fail_streak-1.0.0-py3-none-any.whl

Download URL pytest_max_fail_streak-1.0.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c836e188f25bd34c5a64b24d7b0a33907f456d98523a48245288165401a35c7c
BLAKE2b-256 checksum
How to use checksums
c99a3d98e667ade970d45110c6570b8e220029b19e0f037c4ae685ade0c08c63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pytest-max-fail-streak 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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