skillfed

detect-test-pollution

a tool to detect test pollution

detect-test-pollution v1.2.0 324.3K downloads/30d#7,596 on PyPI205
Permissive license MIT Active released

What it is and what it does

detect-test-pollution is a command-line tool that finds which test is polluting another test when test order matters. Test pollution occurs when a test fails mysteriously in one order but passes when run alone—a common flake symptom. The tool works by bisecting your test suite: given a failing test, it repeatedly runs subsets of your other tests alongside it to narrow down which test causes the failure. It supports two modes: normal detection (when you've identified a failing test) and fuzzing (shuffling tests until a failure appears, then finding its cause).

The tool is pytest-specific and requires your tests to be discoverable and runnable via pytest. It has no runtime dependencies beyond Python itself, making installation and setup straightforward. Bisection typically completes in logarithmic steps relative to your test count, so even large suites can be debugged in reasonable time.

Use it for:

  • Isolate the root cause of a flaky test that fails in CI but passes locally or when run in isolation.
  • Debug test suites where pytest-randomly or pytest-xdist expose hidden test interdependencies.
  • Fuzz a test suite to discover latent pollution before it causes production issues.
  • Identify global state mutations (module-level variables, mocked objects, database state) left behind by tests.
  • Refactor or split a monolithic test file by finding which tests depend on execution order.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Detects test pollution—failures caused by side effects from other tests—by bisecting your test suite to isolate the pair of tests that interact.

Yes. If you maintain a pytest suite and have encountered flaky tests or test-order sensitivity, this tool directly solves a hard debugging problem with low friction and no dependencies. Even if you haven't hit the problem yet, it's lightweight enough to keep on hand. No security concerns, active maintenance, and permissive license.

Install

detect-test-pollution on PyPI

pip

pip install detect-test-pollution

uv

uv add detect-test-pollution

poetry

poetry add detect-test-pollution

Installing detect-test-pollution

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of July 2026 with 205 repository stars.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

Quickstart

pip install detect-test-pollution

detect-test-pollution \
    --failing-test test.py::test_id_here \
    --tests ./tests

Requires pytest to be installed and your tests to be runnable via pytest; requires Python >=3.8.

Verify before relying

  • Effectiveness on very large test suites (thousands of tests) and whether bisection time remains practical.
  • Whether the tool handles parametrized tests, fixtures with side effects, or async test pollution.
  • Support for pytest plugins that affect test ordering or isolation (e.g., pytest-xdist in worker mode).

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 1,051 days since the last release
Last repo commit
First released
Downloads 324,318/month — #7,596 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: detect_test_pollution-1.2.0-py2.py3-none-any.whl

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

test pollution detectionfind flaky test causestest isolation debuggingpytest test dependenciestest order sensitivitybisect failing teststest side effects finder
pytest-plugintest-debuggingflaky-tests

More Testing packages