Registry / testing / pytest-find-dependencies

pytest-find-dependencies

JSON →
library0.6.0pypypi✓ verified 25d ago

A pytest plugin designed to automatically identify dependencies between tests. It achieves this by running tests in various sequences (forward and backward) and employing a binary search algorithm to pinpoint which tests rely on others. This can help uncover hidden state-based dependencies that lead to flaky tests. The current version is 0.6.0 and it is actively maintained.

pip install pytest-find-dependencies
INSTALL
IMPORT
SIG · PYTEST-FIND-DEPEND
P
pytest-find-dependencies
testingpythonv0.6.0
Install
2.8s avg
Import
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 31.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.8s · import 0.000s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest-find-dependencies
This plugin is primarily activated via the pytest command-line interface using the `--find-dependencies` option. Direct Python imports into user test files for its core functionality are not typical.
The functionality is accessed through the pytest CLI, not direct Python imports.

To use `pytest-find-dependencies`, install it and then run `pytest` with the `--find-dependencies` option. The plugin will automatically analyze your tests and report any identified dependencies. The example demonstrates a logical dependency via a shared mutable state, which the plugin should detect.

import pytest # Simulate a shared state that might be modified by one test and read by another _shared_state = {'value': 0} def test_setup_value(): """This test sets a value in the shared state.""" _shared_state['value'] = 10 assert True def test_use_value(): """This test depends on the value being set by test_setup_value.""" assert _shared_state['value'] == 10 def test_independent(): """An independent test with no dependencies.""" assert 1 + 1 == 2 # To run this example, save it as `test_dependencies.py` and execute: # pytest --find-dependencies test_dependencies.py # The output should indicate a dependency found between 'test_use_value' and 'test_setup_value'.
pytest --version
Debug
Known issues
gotchaThe plugin's author suggests considering `detect-test-pollution` as an alternative, noting its superior documentation and greater popularity.
fix
Evaluate `detect-test-pollution` alongside `pytest-find-dependencies` for your use case.
affects: All versions
gotchaWhen `pytest-xdist` (a plugin for parallel test execution) is detected, `pytest-find-dependencies` ensures that its internal dependency-finding test runs are not distributed. This is to prevent breaking the dependency check mechanism.
fix
No specific user action is required; this is handled internally by the plugin to maintain correctness.
affects: All versions
gotchaBy default, the dependency analysis run returns an exit code of 1 if *any* dependency is found, even if all tests pass. If you want the exit code to reflect actual test failures, use the `--fail-on-failed-tests` option.
fix
Add `--fail-on-failed-tests` to your pytest command if you want failing tests to also cause a non-zero exit code.
affects: All versions
gotchaDependencies that stem from a permanent change in the test environment (e.g., a resource being permanently altered) will only be found if the test causing the change runs *before* the dependent test during the plugin's analysis.
fix
Be aware of this limitation; some types of environment-altering dependencies might be missed depending on the initial test ordering.
affects: All versions
gotchaIf you use other plugins that change test order (e.g., `pytest-order`), their ordering rules will only apply to the *first* test run during dependency analysis. Subsequent runs by `pytest-find-dependencies` for dependency isolation will define their own order.
fix
Consider using the `--markers-to-ignore` option to exclude tests with specific ordering markers if you want them explicitly outside the dependency analysis.
affects: All versions
Upgrade
Version history
0.6.0latest on PyPI · released Jul 16, 2025
Audit
Dependencies
pytestrequiredThis is a plugin for pytest, requiring pytest>=6.2.4 to function.
pythonrequiredRequires Python 3.9 or newer.
Agent activity
13 hits · last 30 days
node
10
Amazon
1
Resources
pytest-find-dependencies — pip install pytest-find-dependencies · libregistry