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

Method getnode

src/_pytest/pytester.py:966–983  ·  view source on GitHub ↗

Return the collection node of a file. :param pytest.Config config: A pytest config. See :py:meth:`parseconfig` and :py:meth:`parseconfigure` for creating it. :param os.PathLike[str] arg: Path to the file.

(
        self, config: Config, arg: Union[str, "os.PathLike[str]"]
    )

Source from the content-addressed store, hash-verified

964 )
965
966 def getnode(
967 self, config: Config, arg: Union[str, "os.PathLike[str]"]
968 ) -> Optional[Union[Collector, Item]]:
969 """Return the collection node of a file.
970
971 :param pytest.Config config:
972 A pytest config.
973 See :py:meth:`parseconfig` and :py:meth:`parseconfigure` for creating it.
974 :param os.PathLike[str] arg:
975 Path to the file.
976 """
977 session = Session.from_config(config)
978 assert "::" not in str(arg)
979 p = Path(os.path.abspath(arg))
980 config.hook.pytest_sessionstart(session=session)
981 res = session.perform_collect([str(p)], genitems=False)[0]
982 config.hook.pytest_sessionfinish(session=session, exitstatus=ExitCode.OK)
983 return res
984
985 def getpathnode(self, path: Union[str, "os.PathLike[str]"]):
986 """Return the collection node of a file.

Callers 3

getmodulecolMethod · 0.95
test_global_fileMethod · 0.45
test_pkgfileMethod · 0.45

Calls 4

perform_collectMethod · 0.80
from_configMethod · 0.45
pytest_sessionstartMethod · 0.45
pytest_sessionfinishMethod · 0.45

Tested by

no test coverage detected