MCPcopy
hub / github.com/pytest-dev/pytest / pytest_collection_modifyitems

Method pytest_collection_modifyitems

src/_pytest/cacheprovider.py:436–455  ·  src/_pytest/cacheprovider.py::NFPlugin.pytest_collection_modifyitems
(self, items: list[nodes.Item])

Source from the content-addressed store, hash-verified

434
435 @hookimpl(wrapper=True, tryfirst=True)
436 def pytest_collection_modifyitems(self, items: list[nodes.Item]) -> Generator[None]:
437 res = yield
438
439 if self.active:
440 new_items: dict[str, nodes.Item] = {}
441 other_items: dict[str, nodes.Item] = {}
442 for item in items:
443 if item.nodeid not in self.cached_nodeids:
444 new_items[item.nodeid] = item
445 else:
446 other_items[item.nodeid] = item
447
448 items[:] = self._get_increasing_order(
449 new_items.values()
450 ) + self._get_increasing_order(other_items.values())
451 self.cached_nodeids.update(new_items)
452 else:
453 self.cached_nodeids.update(item.nodeid for item in items)
454
455 return res
456
457 def _get_increasing_order(self, items: Iterable[nodes.Item]) -> list[nodes.Item]:
458 return sorted(items, key=lambda item: item.path.stat().st_mtime, reverse=True)

Callers

nothing calls this directly

Calls 2

_get_increasing_orderMethod · 0.95
updateMethod · 0.80

Tested by

no test coverage detected