detect-test-pollution
a tool to detect test pollution
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-pollutionuv
uv add detect-test-pollutionpoetry
poetry add detect-test-pollutionInstalling 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
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
lib-detect-testenvDetects whether code is running in a test…
permissive · top 5,000 on PyPI
pytest-find-dependenciesA pytest plugin that identifies dependencies…
permissive · top 5,000 on PyPI
pytest-sentryA pytest plugin that sends test failure and…
permissive · top 15,000 on PyPI
pytest-retrypytest-retry is a pytest plugin that…
permissive · top 5,000 on PyPI
pytest-antilruClears functools.lru_cache between pytest test…
permissive · top 15,000 on PyPI
pytest-flakefinderA pytest plugin that runs tests multiple times…
permissive · top 5,000 on PyPI
pytest-prettyA pytest plugin that formats test output with…
permissive · top 5,000 on PyPI
pytest-assumeA pytest plugin that collects and reports…
permissive · top 15,000 on PyPI
pytest-ruffA pytest plugin that integrates ruff code…
unclear · top 15,000 on PyPI
pylint-pytestA Pylint plugin that suppresses false-positive…
permissive · top 15,000 on PyPI