flakehound
Find flaky tests and prove why they're flaky.
Flaky tests pass sometimes and fail sometimes with no code change. Most tools just retry them, which hides the problem. flakehound runs your pytest suite under deliberately hostile conditions, finds the tests that flip, and tells you the cause, with evidence from real runs and a command that reproduces it. It also finds problems that haven't bitten you yet.
- 🆓 Free forever. No accounts, no servers, no paid services.
- 🔒 Local and private. Offline, no telemetry, secrets redacted from every report.
- 🧪 Evidence, not guesses. Every verdict comes from runs that prove it, and every repro command is run for real before it's marked verified.
What it finds
| Problem | Example | What flakehound tells you |
|---|---|---|
| Order dependency | a test leaves an item in a shared cart | the polluter test and the leaked state: shop.cart: [] → ['apple'] |
| Needs another test | a test only passes after a setup-like test ran | the test it secretly depends on |
| Randomness | assert random.random() < 0.8 |
the failing seed, and a repro that replays it |
| Set/dict ordering | comparing ",".join(a_set) to a string |
that PYTHONHASHSEED is the cause |
| Time bombs | breaks on the last day of the month, on Feb 29, in another timezone | the exact date/timezone, before it happens |
| Sleep used as a wait | sleep(0.06) then assert a thread finished |
the exact sleep() line that will fail on a slow CI machine |
| Race conditions | unlocked read-modify-write from threads | that it fails when threads interleave |
Quickstart
pip install flakehound
cd your-project
flakehound run
That's it: no config. Try it on the included demo project to see every kind of problem. The same results as a Markdown report: docs/example-report.md.
⚠️ flakehound runs your test suite (many times). Only run it on code you trust.
Options
| Option | Meaning |
|---|---|
-n, --runs N |
How many times to run the suite (default 10) |
-j, --workers N |
Parallel runs (default: CPU cores − 1, max 8) |
--seed N |
Replay an earlier session exactly |
--json PATH |
Also write a machine-readable report |
--markdown PATH |
Also write a Markdown report (for PR comments) |
--fail-on KINDS |
What makes exit code 1: flaky, time-bomb, racy, broken, suspected, none (default flaky,time-bomb,racy) |
--no-diagnose |
Only detect flaky tests, don't explain them |
--max-diagnose N |
Diagnose at most N flaky tests (default 20) |
--no-probes |
Skip all probe runs (timezones, risky dates, timing) |
--no-timing |
Skip only the timing probes |
--no-step-summary |
Don't add the report to the GitHub Actions job summary |
--timeout S |
Kill a single run after S seconds (default 600) |
-- ARGS |
Anything after -- goes straight to pytest |
Exit codes: 0 no problems, 1 problems found (by default only flaky tests and confirmed
time bombs or racy tests fail a build), 2 usage or collection error.
In CI (GitHub Action)
Hunting runs your suite many times, so run it on a schedule rather than on every push:
# .github/workflows/flakehound.yml
on:
schedule: [{ cron: "0 3 * * *" }] # nightly
workflow_dispatch:
permissions:
contents: read
jobs:
hunt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with: { persist-credentials: false }
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with: { python-version: "3.12" }
- run: pip install -e . # your project and its test dependencies
- uses: urumb/flakehound@v0.1.1 # or pin the release's commit SHA
with:
args: -n 20 # any `flakehound run` options
| Input | Default | Meaning |
|---|---|---|
args |
"" |
Options for flakehound run, e.g. -n 20 --fail-on flaky |
working-directory |
. |
Where your tests live |
report |
flakehound-report.json |
JSON report path (an output, too) |
The Markdown report appears on the run's summary page, and the step fails when
problems are found (see --fail-on). Upload flakehound-report.json with
actions/upload-artifact if you want to keep it, or feed it to
flakehound quarantine add --from-report. Without the action, pip install flakehound
and flakehound run work the same way.
Quarantine
Found a flaky test you can't fix today? Quarantine it so it stops failing the build, without hiding it:
flakehound quarantine add tests/test_cart.py::test_cart_starts_empty --reason "polluted by test_add_item"
flakehound quarantine add --from-report flakehound.json # everything flakehound found
flakehound quarantine list
flakehound quarantine remove tests/test_cart.py::test_cart_starts_empty
- The list is one file,
.flakehound/quarantine.toml: commit it, review it, revert it. flakehound never edits your test files. - Every change shows a diff and asks first (
--yesskips the prompt). - pytest still runs quarantined tests as non-strict
xfail(orskip), so you seeXPASSonce one is fixed. Disable for one run withpytest -p no:flakehound-quarantine. The plugin does nothing when the file doesn't exist. flakehound runignores the quarantine, so quarantined tests keep being hunted.
How it works
flakehound changes one factor at a time, like a science experiment:
- Shake. Run the whole suite many times in parallel, each with a different test order,
randomseed andPYTHONHASHSEED, all recorded. Tests that both pass and fail are flaky; tests that always fail are rechecked, then reported as broken. - Isolate. Run each flaky test alone with the exact seeds of the runs where it failed. Only the order changed, so if it now passes, order is proven to be the cause.
- Find the culprit. Try the tests whose position best correlates with the failure, then shrink the preceding tests with delta debugging, in parallel batches.
- Name the leaked state. Snapshot global state before and after the culprit: module
variables, object and class attributes, environment variables (secret values are never
shown), working directory,
sys.path, project files and logging config. - Seeds. For flaky tests that aren't about order, swap one seed at a time between a failing and a passing run: the one that flips the result is the cause. If identical seeds still give different results, the test is nondeterministic.
- Time bomb probes. Runs with the baseline's exact order and seeds, but in UTC+14, UTC−12, just before midnight, on the last day of the month, on New Year's Eve and on Feb 29. The clock is shifted, not frozen, so code that waits on time still works.
- Timing probes. One run where every
sleep()on the test's main thread is 20× shorter (background work keeps its real speed, like a slow machine), and one where threads switch far more often. Then onesleep()call site at a time, to find the line. - Confirm and verify. Findings are re-run, and each printed repro command is run for real; it's marked verified only if it fails exactly as printed.
Repro commands that replay a seed, clock or timing stress use flakehound's pytest plugin
(-p flakehound.adapters.pytest.plugin), so they need flakehound installed. That plugin
never loads into your normal pytest runs on its own.
How it compares
| Tool | Retries | Detects | Explains why | Free & local |
|---|---|---|---|---|
| pytest-rerunfailures, flaky | ✅ | ❌ | ❌ | ✅ |
| pytest-randomly | ❌ | order/seed issues show up | ❌ | ✅ |
| detect-test-pollution | ❌ | ❌ | the polluter test (you drive it) | ✅ |
| Trunk, BuildPulse, Datadog | ✅ | from CI history | little | ❌ paid / uploads data |
| flakehound | ❌ (on purpose) | ✅ + time bombs + racy tests | polluter, leaked state, seed, date, timezone, sleep() line, race |
✅ |
Limitations
- Python + pytest only, for now.
asyncio.sleepis not shortened by the timing probes.- State hidden in fixtures, databases or external services can't be seen by the leak detector; the report says so instead of guessing.
- Thread stress exposes races that happen around Python function calls.
- Hunting takes many runs of your suite: use
-n,-jand--max-diagnoseon large suites.
Roadmap
- GitHub Actions history mode: find flaky tests from past CI runs without running anything
- Adapters for Jest/Vitest, Go test and JUnit
- Optional AI explanations (local models via Ollama, or your own key; never required)
See CHANGELOG.md for what's in each release.
Contributing and security
Contributions are welcome: see CONTRIBUTING.md. To report a vulnerability privately, see SECURITY.md.
License
MIT
Metadata
Release files for flakehound 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flakehound-0.1.1.tar.gz | 71.5 kB | With provenance | Details for flakehound-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flakehound-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for flakehound-0.1.1-py3-none-any.whl |
Total release size: 142.5 kB
Release files / flakehound-0.1.1.tar.gz
| Download URL | flakehound-0.1.1.tar.gz |
|---|---|
| Size | 71.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44136e08d7b87aab60d56b79c60f8be3015c61857d3cb56d955846ff699e085e
|
|
BLAKE2b-256 checksum How to use checksums |
7b6e0af78ffc4589cf22fa6fec7f44a76f561fdead5cf7ce0ab458512ec31af1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / flakehound-0.1.1-py3-none-any.whl
| Download URL | flakehound-0.1.1-py3-none-any.whl |
|---|---|
| Size | 71.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e50b4c5b8b74bbd023aab984dd3417b8a1e4b44c264f7eee4cefdaf69d9e7d38
|
|
BLAKE2b-256 checksum How to use checksums |
5643beac000c06b204c81bcdd51198be1ce785ac36ab2f1f3a5eba58142dfcc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for flakehound 0.1.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for flakehound-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA 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.