Skip to content

Commit 877cd71

Browse files
authored
Don't break --failed-first when re-ordering tests (#820)
Pytest-django 3.5.0 attempts to run tests in the same order as Django: Issue #223, Commit 5a79fba Pytest itself can re-order tests to prioritize previously failed tests (--failed-first), incremental runs of the test suite (--stepwise), etc. However, pytest-django's re-ordering clobbers pytest's, which can break those options as reported in #819. By applying the @pytest.hookimpl(tryfirst=True) decorator to pytest_collection_modifyitems(), pytest-django's re-ordering happens first, and does not clobber the later re-ordering performed by pytest. Fixes #819
1 parent 619dd30 commit 877cd71

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

pytest_django/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ def pytest_runtest_setup(item):
415415
_disable_class_methods(item.cls)
416416

417417

418+
@pytest.hookimpl(tryfirst=True)
418419
def pytest_collection_modifyitems(items):
419420
def get_order_number(test):
420421
marker_db = test.get_closest_marker('django_db')

0 commit comments

Comments
 (0)