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

Method _collectfile

src/_pytest/python.py:704–726  ·  view source on GitHub ↗
(
        self, fspath: Path, handle_dupes: bool = True
    )

Source from the content-addressed store, hash-verified

702 return True
703
704 def _collectfile(
705 self, fspath: Path, handle_dupes: bool = True
706 ) -> Sequence[nodes.Collector]:
707 assert (
708 fspath.is_file()
709 ), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
710 fspath, fspath.is_dir(), fspath.exists(), fspath.is_symlink()
711 )
712 ihook = self.session.gethookproxy(fspath)
713 if not self.session.isinitpath(fspath):
714 if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
715 return ()
716
717 if handle_dupes:
718 keepduplicates = self.config.getoption("keepduplicates")
719 if not keepduplicates:
720 duplicate_paths = self.config.pluginmanager._duplicatepaths
721 if fspath in duplicate_paths:
722 return ()
723 else:
724 duplicate_paths.add(fspath)
725
726 return ihook.pytest_collect_file(file_path=fspath, parent=self) # type: ignore[no-any-return]
727
728 def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
729 this_path = self.path.parent

Callers 1

collectMethod · 0.95

Calls 5

pytest_collect_fileMethod · 0.80
formatMethod · 0.45
gethookproxyMethod · 0.45
isinitpathMethod · 0.45
getoptionMethod · 0.45

Tested by

no test coverage detected