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

Method collect

src/_pytest/main.py:564–585  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

562 return super().from_parent(parent=parent, path=path)
563
564 def collect(self) -> Iterable[nodes.Item | nodes.Collector]:
565 config = self.config
566 col: nodes.Collector | None
567 cols: Sequence[nodes.Collector]
568 ihook = self.ihook
569 for direntry in scandir(self.path):
570 if direntry.is_dir():
571 path = Path(direntry.path)
572 if not self.session.isinitpath(path, with_parents=True):
573 if ihook.pytest_ignore_collect(collection_path=path, config=config):
574 continue
575 col = ihook.pytest_collect_directory(path=path, parent=self)
576 if col is not None:
577 yield col
578
579 elif direntry.is_file():
580 path = Path(direntry.path)
581 if not self.session.isinitpath(path):
582 if ihook.pytest_ignore_collect(collection_path=path, config=config):
583 continue
584 cols = ihook.pytest_collect_file(file_path=path, parent=self)
585 yield from cols
586
587
588@final

Callers 4

gc_collect_harderFunction · 0.45
collect_by_nameMethod · 0.45
collectFunction · 0.45

Calls 3

scandirFunction · 0.90
pytest_collect_fileMethod · 0.80
isinitpathMethod · 0.45

Tested by 2

collect_by_nameMethod · 0.36