{"id":4213,"library":"pytest-find-dependencies","title":"pytest-find-dependencies","description":"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.","status":"active","version":"0.6.0","language":"python","source_language":"en","source_url":"https://github.com/svenkoehler/pytest-find-dependencies","tags":["pytest-plugin","testing","dependencies","test-analysis","flaky-tests"],"install":[{"cmd":"pip install pytest-find-dependencies","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"This is a plugin for pytest, requiring pytest>=6.2.4 to function.","package":"pytest","optional":false},{"reason":"Requires Python 3.9 or newer.","package":"python","optional":false}],"imports":[{"note":"The functionality is accessed through the pytest CLI, not direct Python imports.","symbol":"pytest-find-dependencies","correct":"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."}],"quickstart":{"code":"import pytest\n\n# Simulate a shared state that might be modified by one test and read by another\n_shared_state = {'value': 0}\n\ndef test_setup_value():\n    \"\"\"This test sets a value in the shared state.\"\"\"\n    _shared_state['value'] = 10\n    assert True\n\ndef test_use_value():\n    \"\"\"This test depends on the value being set by test_setup_value.\"\"\"\n    assert _shared_state['value'] == 10\n\ndef test_independent():\n    \"\"\"An independent test with no dependencies.\"\"\"\n    assert 1 + 1 == 2\n\n# To run this example, save it as `test_dependencies.py` and execute:\n# pytest --find-dependencies test_dependencies.py\n# The output should indicate a dependency found between 'test_use_value' and 'test_setup_value'.","lang":"python","description":"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."},"warnings":[{"fix":"Evaluate `detect-test-pollution` alongside `pytest-find-dependencies` for your use case.","message":"The plugin's author suggests considering `detect-test-pollution` as an alternative, noting its superior documentation and greater popularity.","severity":"gotcha","affected_versions":"All versions"},{"fix":"No specific user action is required; this is handled internally by the plugin to maintain correctness.","message":"When `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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Add `--fail-on-failed-tests` to your pytest command if you want failing tests to also cause a non-zero exit code.","message":"By 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware of this limitation; some types of environment-altering dependencies might be missed depending on the initial test ordering.","message":"Dependencies 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider using the `--markers-to-ignore` option to exclude tests with specific ordering markers if you want them explicitly outside the dependency analysis.","message":"If 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.6.0':58 'achiev':16 'activ':62 'algorithm':32 'analysi':71 'automat':10 'backward':26 'base':47 'binari':30 'current':55 'depend':4,12,48,68 'design':8 'employ':28 'find':3 'flaki':52,73 'flaky-test':72 'forward':24 'help':42 'hidden':44 'identifi':11 'lead':50 'maintain':63 'other':39 'pinpoint':34 'plugin':7,66 'pytest':2,6,65 'pytest-find-depend':1 'pytest-plugin':64 'reli':37 'run':19 'search':31 'sequenc':23 'state':46 'state-bas':45 'test':14,20,36,53,67,70,74 'test-analysi':69 'uncov':43 'various':22 'version':56","created_at":"2026-04-12T03:45:47.229584+00:00","updated_at":"2026-04-12T03:45:47.229584+00:00","problems":{"verify_error":"no import statement found"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.6.0","cli_name":"pytest","cli_version":"pytest 9.0.3","type":"library","homepage":null,"github":"https://github.com/mrbean-bremen/pytest-find-dependencies","docs":null,"changelog":"https://github.com/mrbean-bremen/pytest-find-dependencies/blob/main/CHANGELOG.rst","pypi":"https://pypi.org/project/pytest-find-dependencies/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-05","install_tag":null}}