{"id":10140,"library":"pytest-depends","title":"pytest-depends","description":"pytest-depends is a pytest plugin that enables defining dependencies between tests. If a test marked as a dependency fails or is skipped, any tests dependent on it will also be skipped. The current version is 1.0.1. The library is in maintenance mode with no recent updates since late 2021.","status":"maintenance","version":"1.0.1","language":"en","source_language":"en","source_url":"https://github.com/teepy/pytest-depends","tags":["pytest","testing","test-dependencies","plugin"],"install":[{"cmd":"pip install pytest-depends","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for pytest plugin functionality.","package":"pytest","optional":false}],"imports":[{"note":"The `depends` decorator is commonly imported via an alias from the top-level package.","wrong":"from pytest_depends import depends","symbol":"depends","correct":"import pytest_depends as depends"}],"quickstart":{"code":"import pytest\nimport pytest_depends as depends\n\n# This test will pass and its dependent will run\ndef test_dependency_a_success():\n    print(\"\\nRunning test_dependency_a_success\")\n    assert True\n\n# This test will fail and its dependent will be skipped\ndef test_dependency_b_failure():\n    print(\"\\nRunning test_dependency_b_failure\")\n    assert False\n\n@depends.depends(on=['test_dependency_a_success'])\ndef test_dependent_on_success_runs():\n    print(\"\\nRunning test_dependent_on_success_runs\")\n    assert True\n\n@depends.depends(on=['test_dependency_b_failure'])\ndef test_dependent_on_failure_is_skipped():\n    print(\"\\nRunning test_dependent_on_failure_is_skipped (expected to be skipped)\")\n    # This assert will not be reached if the test is skipped\n    assert True\n\n# To run this example, save it as 'test_my_deps.py' and run 'pytest' from your terminal.","lang":"python","description":"This quickstart demonstrates defining dependent tests. `test_dependent_on_success_runs` will execute because its dependency `test_dependency_a_success` passes. `test_dependent_on_failure_is_skipped` will be marked as skipped by pytest because its dependency `test_dependency_b_failure` fails."},"warnings":[{"fix":"Understand that the dependent test will simply be marked SKIPPED by pytest, preventing its execution without attempting to correct or retry the failing dependency.","message":"pytest-depends skips dependent tests if a dependency fails; it does not re-run the dependency or alter its outcome. A 'skipped' test is distinct from a 'failed' test.","severity":"gotcha","affected_versions":"All versions (1.0.1)"},{"fix":"Test thoroughly with your specific pytest and Python environment versions. If encountering issues, consider reviewing open issues on the GitHub repository or exploring alternative dependency management plugins for pytest.","message":"The pytest-depends project has not been updated in over two years (since November 2021), which may lead to compatibility issues with newer versions of pytest or Python.","severity":"gotcha","affected_versions":"1.0.1 and older"},{"fix":"Ensure the string in the 'on' list precisely corresponds to the target test function's name (e.g., `test_my_feature`) or its complete node ID if it's part of a parameterized set (e.g., `test_my_feature[param1-value]`).","message":"Dependency names provided in `@depends.depends(on=['...'])` must exactly match the test function names or their full pytest node IDs, including parameters for parameterized tests.","severity":"gotcha","affected_versions":"All versions (1.0.1)"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the plugin using pip: `pip install pytest-depends`","cause":"The `pytest-depends` plugin is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'pytest_depends'"},{"fix":"Import `pytest_depends` and alias it as `depends`: `import pytest_depends as depends`","cause":"The `depends` decorator is typically imported via an alias from the top-level package, not directly as a submodule attribute, leading to an `AttributeError` if attempted.","error":"AttributeError: module 'pytest_depends' has no attribute 'depends'"},{"fix":"Double-check the string value(s) in `on=['your_dependency_name']`. It must be the exact name of the test function (e.g., `test_my_function`) or its full node ID for parameterized tests.","cause":"The dependency name specified in the `on` list of `@depends.depends()` does not correspond to an actual, discoverable test function name or pytest node ID.","error":"PytestCollectionWarning: Cannot find dependency 'missing_test_name' for '<test_node_id>'"}]}