pytest-dependency

0.6.1 · active · verified Sat Apr 11

pytest-dependency is a plugin for the pytest Python testing framework that allows you to manage dependencies between tests. Tests marked as dependent on others will be automatically skipped if any of their dependencies fail or are skipped. The current version is 0.6.1, released in February 2026, and the project maintains an active, albeit irregular, release cadence.

Warnings

Install

Imports

Quickstart

This example demonstrates basic test dependency management. `test_a` is marked to deliberately fail. `test_c` depends on `test_a` and will be skipped. `test_e` depends on both `test_b` (which passes) and `test_c` (which is skipped), leading to `test_e` also being skipped.

import pytest

@pytest.mark.dependency()
@pytest.mark.xfail(reason="deliberate fail", raises=AssertionError)
def test_a():
    assert False

@pytest.mark.dependency()
def test_b():
    assert True

@pytest.mark.dependency(depends=["test_a"])
def test_c():
    assert True

@pytest.mark.dependency(depends=["test_b"])
def test_d():
    assert True

@pytest.mark.dependency(depends=["test_b", "test_c"])
def test_e():
    assert True

# To run this, save as `test_deps.py` and run `pytest -rsx test_deps.py`

view raw JSON →