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

Method path

src/_pytest/_code/code.py:85–100  ·  view source on GitHub ↗

Return a path object pointing to source code, or an ``str`` in case of ``OSError`` / non-existing file.

(self)

Source from the content-addressed store, hash-verified

83
84 @property
85 def path(self) -> Path | str:
86 """Return a path object pointing to source code, or an ``str`` in
87 case of ``OSError`` / non-existing file."""
88 filename = inspect.getfile(self.raw)
89 if not filename:
90 return ""
91 try:
92 p = absolutepath(filename)
93 # maybe don't try this checking
94 if not p.exists():
95 raise OSError("path check failed.")
96 return p
97 except OSError:
98 # XXX maybe try harder like the weird logic
99 # in the standard lib [linecache.updatecache] does?
100 return filename
101
102 @property
103 def fullsource(self) -> Source | None:

Callers

nothing calls this directly

Calls 2

absolutepathFunction · 0.90
existsMethod · 0.45

Tested by

no test coverage detected