Registry / testing / pytest-depends

pytest-depends

JSON →
library1.0.1pypypi✓ verified 87d ago

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-depends
INSTALL
IMPORT
SIG · PYTEST-DEPENDS
P
pytest-depends
testingpythonv1.0.1
Install
3.8s avg
Import
738ms
Disk
46MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.1 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.778s · 45.3MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.8s · import 0.698s · 46MB
46MB installed
● package 46MB
Code
Verified usage

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

depends
import pytest_depends as depends
from pytest_depends import depends
The `depends` decorator is commonly imported via an alias from the top-level package.

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.

import pytest import pytest_depends as depends # This test will pass and its dependent will run def test_dependency_a_success(): print("\nRunning test_dependency_a_success") assert True # This test will fail and its dependent will be skipped def test_dependency_b_failure(): print("\nRunning test_dependency_b_failure") assert False @depends.depends(on=['test_dependency_a_success']) def test_dependent_on_success_runs(): print("\nRunning test_dependent_on_success_runs") assert True @depends.depends(on=['test_dependency_b_failure']) def test_dependent_on_failure_is_skipped(): print("\nRunning test_dependent_on_failure_is_skipped (expected to be skipped)") # This assert will not be reached if the test is skipped assert True # To run this example, save it as 'test_my_deps.py' and run 'pytest' from your terminal.
Debug
Known issues
gotchapytest-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.
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.
affects: All versions (1.0.1)
gotchaThe 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.
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.
affects: 1.0.1 and older
gotchaDependency names provided in `@depends.depends(on=['...'])` must exactly match the test function names or their full pytest node IDs, including parameters for parameterized tests.
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]`).
affects: All versions (1.0.1)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytest_depends'
The `pytest-depends` plugin is not installed in the current Python environment.
fix
Install the plugin using pip: `pip install pytest-depends`
AttributeError: module 'pytest_depends' has no attribute 'depends'
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.
fix
Import `pytest_depends` and alias it as `depends`: `import pytest_depends as depends`
PytestCollectionWarning: Cannot find dependency 'missing_test_name' for '<test_node_id>'
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.
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.
Upgrade
Version history
1.0.1latest on PyPI · released Apr 5, 2020
Audit
Dependencies
pytestrequiredRequired for pytest plugin functionality.
Agent activity
14 hits · last 30 days
node
12
Resources
pytest-depends — pip install pytest-depends · libregistry