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

Method getmodpath

src/_pytest/python.py:314–329  ·  view source on GitHub ↗

Return Python path relative to the containing module.

(self, stopatmodule: bool = True, includemodule: bool = False)

Source from the content-addressed store, hash-verified

312 return getattr(obj, self.name)
313
314 def getmodpath(self, stopatmodule: bool = True, includemodule: bool = False) -> str:
315 """Return Python path relative to the containing module."""
316 chain = self.listchain()
317 chain.reverse()
318 parts = []
319 for node in chain:
320 name = node.name
321 if isinstance(node, Module):
322 name = os.path.splitext(name)[0]
323 if stopatmodule:
324 if includemodule:
325 parts.append(name)
326 break
327 parts.append(name)
328 parts.reverse()
329 return ".".join(parts)
330
331 def reportinfo(self) -> Tuple[Union["os.PathLike[str]", str], Optional[int], str]:
332 # XXX caching?

Callers 3

reportinfoMethod · 0.95
test_example_items1Method · 0.80

Calls 2

listchainMethod · 0.80
appendMethod · 0.80