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

Method _collect_path

src/_pytest/main.py:748–777  ·  view source on GitHub ↗

Create a Collector for the given path. `path_cache` makes it so the same Collectors are returned for the same path.

(
        self,
        path: Path,
        path_cache: dict[Path, Sequence[nodes.Collector]],
    )

Source from the content-addressed store, hash-verified

746 return proxy
747
748 def _collect_path(
749 self,
750 path: Path,
751 path_cache: dict[Path, Sequence[nodes.Collector]],
752 ) -> Sequence[nodes.Collector]:
753 """Create a Collector for the given path.
754
755 `path_cache` makes it so the same Collectors are returned for the same
756 path.
757 """
758 if path in path_cache:
759 return path_cache[path]
760
761 if path.is_dir():
762 ihook = self.gethookproxy(path.parent)
763 col: nodes.Collector | None = ihook.pytest_collect_directory(
764 path=path, parent=self
765 )
766 cols: Sequence[nodes.Collector] = (col,) if col is not None else ()
767
768 elif path.is_file():
769 ihook = self.gethookproxy(path)
770 cols = ihook.pytest_collect_file(file_path=path, parent=self)
771
772 else:
773 # Broken symlink or invalid/missing file.
774 cols = ()
775
776 path_cache[path] = cols
777 return cols
778
779 @overload
780 def perform_collect(

Callers 1

collectMethod · 0.80

Calls 2

gethookproxyMethod · 0.95
pytest_collect_fileMethod · 0.80

Tested by

no test coverage detected