File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed 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(
274
274
"""Called after collection has been performed. May filter or re-order
275
275
the items in-place.
276
276
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
+
277
282
:param session: The pytest session object.
278
283
:param config: The pytest config object.
279
284
:param items: List of item objects.
@@ -454,6 +459,12 @@ def pytest_collectreport(report: CollectReport) -> None:
454
459
def pytest_deselected (items : Sequence [Item ]) -> None :
455
460
"""Called for deselected test items, e.g. by keyword.
456
461
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
+
457
468
May be called multiple times.
458
469
459
470
:param items:
You can’t perform that action at this time.
0 commit comments