File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Clarify that the `pytest_deselected ` hook should be called from `pytest_collection_modifyitems ` hook implementations when items are deselected.
Original file line number Diff line number Diff line change @@ -274,6 +274,11 @@ def pytest_collection_modifyitems(
274274 """Called after collection has been performed. May filter or re-order
275275 the items in-place.
276276
277+ When items are deselected (filtered out from ``items``),
278+ the hook :hook:`pytest_deselected` must be called explicitly
279+ with the deselected items to properly notify other plugins,
280+ e.g. with ``config.hook.pytest_deselected(deselected_items)``.
281+
277282 :param session: The pytest session object.
278283 :param config: The pytest config object.
279284 :param items: List of item objects.
@@ -454,6 +459,12 @@ def pytest_collectreport(report: CollectReport) -> None:
454459def pytest_deselected (items : Sequence [Item ]) -> None :
455460 """Called for deselected test items, e.g. by keyword.
456461
462+ Note that this hook has two integration aspects for plugins:
463+
464+ - it can be *implemented* to be notified of deselected items
465+ - it must be *called* from :hook:`pytest_collection_modifyitems`
466+ implementations when items are deselected (to properly notify other plugins).
467+
457468 May be called multiple times.
458469
459470 :param items:
You can’t perform that action at this time.
0 commit comments