pytest-ordering icon indicating copy to clipboard operation
pytest-ordering copied to clipboard

pytest-ordering doesn't honor test dependencies

Open FFY00 opened this issue 6 years ago • 5 comments
trafficstars

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

FFY00 avatar Aug 26 '19 14:08 FFY00

What do you think the behavior should be in this case?

ftobia avatar Sep 09 '19 19:09 ftobia

The dependencies should be run first.

FFY00 avatar Sep 09 '19 19:09 FFY00

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

ftesser avatar Oct 03 '19 15:10 ftesser

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.

phillip-lu-axomic avatar Feb 21 '20 00:02 phillip-lu-axomic

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.

mrbean-bremen avatar Jan 24 '21 08:01 mrbean-bremen