Skip to content

Commit 632d3ef

Browse files
committed
use tryfirst instead
1 parent d5bbf61 commit 632d3ef

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pytest_run_parallel/plugin.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,15 @@ def pytest_runtestloop(self, session: pytest.Session):
238238

239239
return True
240240

241-
@pytest.hookimpl(trylast=True)
241+
# This is tryfirst=True because we need our plugin's pytest_collection_finish
242+
# to be called before the terminal plugin's pytest_collection_finish:
243+
#
244+
# - pytest's terminal plugin hooks pytest_collection_finish, which calls
245+
# pytest_report_collectionfinish
246+
# - we hook pytest_report_collectionfinish, assuming _handle_collected_item
247+
# has already been called for all items when pytest_report_collectionfinish
248+
# is called
249+
@pytest.hookimpl(tryfirst=True)
242250
def pytest_collection_finish(self, session):
243251
for item in session.items:
244252
self._handle_collected_item(item)

0 commit comments

Comments
 (0)