pytest plugin for controlling execution flow
Project description
What?
pytest-node-dependency is a pytest plugin that allows you to define dependencies between tests and reorder their execution based on those dependencies. This plugin ensures that tests with dependencies run after their required prerequisites have completed successfully.
How to install?
pip install pytest-node-dependency
how to use?
To set up a test dependency, decorate the test function with the depends
mark and provide a list of dependencies via the on
keyword argument to the decorator. Dependencies can be specified by name only when in the same file as the test being decorated or by the pytest node path for tests in other files/classes.
import pytest
def test_second(request):
print("second")
assert request.session.items[1].name == 'test_second'
@pytest.mark.depends(on=["test_plugin.py::test_second"])
def test_last(request):
print("last")
assert request.session.items[2].name == 'test_last'
def test_first(request):
print("first")
assert request.session.items[0].name == 'test_first'
Limitations and known issues:
- The plugin logic makes tests run one after the other in a serial way, as a result, x-dist isn't supported (currently).
- All the tests without depednecy (both dependent on and depends on) will run first, afterwards all tests with connections will run (e.g. the list of items will be as described)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pytest-node-dependency-1.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd6979bae3998e5c7695a0c80fb1ac1e9fe0e4458d462bf2adcc52364f6322a8 |
|
MD5 | 2af176835cca8969b8ffb4858f9549c9 |
|
BLAKE2b-256 | e477a4679642b657ff2b21740b5e7a65ed7108a581ac0fccf257a2a63995b8b4 |
Close
Hashes for pytest_node_dependency-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ff67ac1a2f6ef736cf29c2f10fa81917282eb8fbb8bbed8dcb43300bae5863c |
|
MD5 | 0c56d6981e26ec1ed3bc6b1dc77715ff |
|
BLAKE2b-256 | c6f4a84065e6301a39ec1c5be26291a95e9122b39de6f850ef0185bd9ce2c3d1 |