Find the Test That's Leaking Before the One That Fails

A tool for finding the causes of unstable Python tests

Find the Test That's Leaking Before the One That Fails

pytest-leak-finder is a plugin that helps you pinpoint which test is causing another test to fail when run together. It uses a binary search approach, similar to git bisect, to narrow down the culprit. After you run your test suite with the plugin, it identifies the failing test as the target and then systematically tests subsets of the preceding tests to isolate the one that leaves behind state causing the failure. This tool is especially useful for debugging flaky tests that pass in isolation but fail in a suite.

You have a test that passes when executed alone but fails when running its suite. What's happening? My two cents that some previous test keeps the things dirty. But wich one/s, maybe the previous are a lot, right?

More from this day

2026-08-03