pytest-ordering
pytest-ordering copied to clipboard
pytest-ordering doesn't honor test dependencies
import pytest
def test_a():
pass
@pytest.mark.dependency(depends=['test_a'])
@pytest.mark.first
def test_b():
pass
$ pytest -v -x -s test.py
================================== test session starts ==================================
platform linux -- Python 3.7.4, pytest-5.1.1, py-1.8.0, pluggy-0.12.0 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /home/anubis/git/ratbag-emu
plugins: ordering-0.6
collected 2 items
test.py::test_b PASSED
test.py::test_a PASSED
What do you think the behavior should be in this case?
The dependencies should be run first.
Hi all, I also think that should be very useful to automatically reorder the test execution based on dependencies. Should be nice if pytest-dependency and pytest-ordering will join their efforts.
This issue of pytest-dependency is related: https://github.com/RKrahl/pytest-dependency/issues/20
I didn't want a dependency on networkx for @jwineinger 's solution (https://gist.github.com/jwineinger/e41473cd5500554a189d8c97ac28f883), so I rolled my own solution that worked for my (admittedly) not-so-large test set: https://gist.github.com/phillip-lu-axomic/3a8c8c246975667da3162decac9b5f2e
Hopefully this is of some use to others.
FWIW, I also added an option to order dependencies in my fork, though it looks like the issue is on the way to be solved in pytest-dependency.