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-dependenciesVerified import paths — ran on the pinned version, not inferred.
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.
Evaluate `detect-test-pollution` alongside `pytest-find-dependencies` for your use case.
No specific user action is required; this is handled internally by the plugin to maintain correctness.
Add `--fail-on-failed-tests` to your pytest command if you want failing tests to also cause a non-zero exit code.
Be aware of this limitation; some types of environment-altering dependencies might be missed depending on the initial test ordering.
Consider using the `--markers-to-ignore` option to exclude tests with specific ordering markers if you want them explicitly outside the dependency analysis.