MCPcopy Create free account
hub / github.com/pytest-dev/pytest / pytest_collection_modifyitems

Method pytest_collection_modifyitems

src/_pytest/cacheprovider.py:400–419  ·  view source on GitHub ↗
(
        self, items: List[nodes.Item]
    )

Source from the content-addressed store, hash-verified

398
399 @hookimpl(hookwrapper=True, tryfirst=True)
400 def pytest_collection_modifyitems(
401 self, items: List[nodes.Item]
402 ) -> Generator[None, None, None]:
403 yield
404
405 if self.active:
406 new_items: Dict[str, nodes.Item] = {}
407 other_items: Dict[str, nodes.Item] = {}
408 for item in items:
409 if item.nodeid not in self.cached_nodeids:
410 new_items[item.nodeid] = item
411 else:
412 other_items[item.nodeid] = item
413
414 items[:] = self._get_increasing_order(
415 new_items.values()
416 ) + self._get_increasing_order(other_items.values())
417 self.cached_nodeids.update(new_items)
418 else:
419 self.cached_nodeids.update(item.nodeid for item in items)
420
421 def _get_increasing_order(self, items: Iterable[nodes.Item]) -> List[nodes.Item]:
422 return sorted(items, key=lambda item: item.path.stat().st_mtime, reverse=True) # type: ignore[no-any-return]

Callers

nothing calls this directly

Calls 2

_get_increasing_orderMethod · 0.95
updateMethod · 0.80

Tested by

no test coverage detected