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

Function getlocation

src/_pytest/compat.py:75–86  ·  view source on GitHub ↗
(function, curdir: str | os.PathLike[str] | None = None)

Source from the content-addressed store, hash-verified

73
74
75def getlocation(function, curdir: str | os.PathLike[str] | None = None) -> str:
76 function = get_real_func(function)
77 fn = Path(inspect.getfile(function))
78 lineno = function.__code__.co_firstlineno
79 if curdir is not None:
80 try:
81 relfn = fn.relative_to(curdir)
82 except ValueError:
83 pass
84 else:
85 return f"{relfn}:{lineno + 1}"
86 return f"{fn}:{lineno + 1}"
87
88
89def num_mock_patch_args(function) -> int:

Callers 5

__call__Method · 0.90
_pretty_fixture_pathFunction · 0.90
get_best_relpathFunction · 0.90
_showfixtures_mainFunction · 0.90

Calls 1

get_real_funcFunction · 0.85

Tested by

no test coverage detected