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.
pip install pytest-dependsVerified import paths — ran on the pinned version, not inferred.
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.
Understand that the dependent test will simply be marked SKIPPED by pytest, preventing its execution without attempting to correct or retry the failing dependency.
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.
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]`).
Install the plugin using pip: `pip install pytest-depends`
Import `pytest_depends` and alias it as `depends`: `import pytest_depends as depends`
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.