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

Method getnode

src/_pytest/pytester.py:993–1010  ·  view source on GitHub ↗

Get the collection node of a file. :param config: A pytest config. See :py:meth:`parseconfig` and :py:meth:`parseconfigure` for creating it. :param arg: Path to the file. :returns: The node.

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

Source from the content-addressed store, hash-verified

991 )
992
993 def getnode(self, config: Config, arg: str | os.PathLike[str]) -> Collector | Item:
994 """Get the collection node of a file.
995
996 :param config:
997 A pytest config.
998 See :py:meth:`parseconfig` and :py:meth:`parseconfigure` for creating it.
999 :param arg:
1000 Path to the file.
1001 :returns:
1002 The node.
1003 """
1004 session = Session.from_config(config)
1005 assert "::" not in str(arg)
1006 p = Path(os.path.abspath(arg))
1007 config.hook.pytest_sessionstart(session=session)
1008 res = session.perform_collect([str(p)], genitems=False)[0]
1009 config.hook.pytest_sessionfinish(session=session, exitstatus=ExitCode.OK)
1010 return res
1011
1012 def getpathnode(self, path: str | os.PathLike[str]) -> Collector | Item:
1013 """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