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

Function iterparentnodeids

src/_pytest/nodes.py:51–93  ·  view source on GitHub ↗

Return the parent node IDs of a given node ID, inclusive. For the node ID "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source" the result would be "" "testing" "testing/code" "testing/code/test_excinfo.py" "testing/code/te

(nodeid: str)

Source from the content-addressed store, hash-verified

49
50
51def iterparentnodeids(nodeid: str) -> Iterator[str]:
52 """Return the parent node IDs of a given node ID, inclusive.
53
54 For the node ID
55
56 "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source"
57
58 the result would be
59
60 ""
61 "testing"
62 "testing/code"
63 "testing/code/test_excinfo.py"
64 "testing/code/test_excinfo.py::TestFormattedExcinfo"
65 "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source"
66
67 Note that / components are only considered until the first ::.
68 """
69 pos = 0
70 first_colons: Optional[int] = nodeid.find("::")
71 if first_colons == -1:
72 first_colons = None
73 # The root Session node - always present.
74 yield ""
75 # Eagerly consume SEP parts until first colons.
76 while True:
77 at = nodeid.find(SEP, pos, first_colons)
78 if at == -1:
79 break
80 if at > 0:
81 yield nodeid[:at]
82 pos = at + len(SEP)
83 # Eagerly consume :: parts.
84 while True:
85 at = nodeid.find("::", pos)
86 if at == -1:
87 break
88 if at > 0:
89 yield nodeid[:at]
90 pos = at + len("::")
91 # The node ID itself.
92 if nodeid:
93 yield nodeid
94
95
96def _check_path(path: Path, fspath: LEGACY_PATH) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected