Skip to content

Instantly share code, notes, and snippets.

@ftesser
ftesser / conftest.py
Last active April 23, 2019 04:37 — forked from jwineinger/conftest.py
reorder pytest tests based on dependencies
def pytest_collection_modifyitems(session, config, items):
"""Reorder the execution of tests based on the dependency marks on tests.
To setup a test dependency, decorate the test function with the "depends"
mark and give a list of dependencies via the "on" keyword arg to the
decorator. Dependencies can be specified by name only when in the same
file as the test being decorated, or by pytest node path for tests in
other files/classes.
@pytest.mark.depends(on=["test_in_same_file",