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

Method path

src/_pytest/_code/code.py:87–101  ·  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

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

Callers

nothing calls this directly

Calls 1

absolutepathFunction · 0.90

Tested by

no test coverage detected