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

Method getparent

src/_pytest/nodes.py:417–424  ·  view source on GitHub ↗

Get the next parent node (including self) which is an instance of the given class.

(self, cls: Type[_NodeType])

Source from the content-addressed store, hash-verified

415 self.session._setupstate.addfinalizer(fin, self)
416
417 def getparent(self, cls: Type[_NodeType]) -> Optional[_NodeType]:
418 """Get the next parent node (including self) which is an instance of
419 the given class."""
420 current: Optional[Node] = self
421 while current and not isinstance(current, cls):
422 current = current.parent
423 assert current is None or isinstance(current, cls)
424 return current
425
426 def _prunetraceback(self, excinfo: ExceptionInfo[BaseException]) -> None:
427 pass

Callers 11

moduleMethod · 0.80
clsMethod · 0.80
instanceMethod · 0.80
_genfunctionsMethod · 0.80
get_scope_nodeFunction · 0.80
clsMethod · 0.80
moduleMethod · 0.80
pytest_runtest_setupFunction · 0.80

Calls

no outgoing calls

Tested by 4

pytest_runtest_setupFunction · 0.64