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

Method getmodpath

src/_pytest/python.py:311–324  ·  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

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

Calls 3

iter_parentsMethod · 0.80
appendMethod · 0.80
joinMethod · 0.80