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

Function getlocation

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

Source from the content-addressed store, hash-verified

84
85
86def getlocation(function, curdir: Optional[str] = None) -> str:
87 function = get_real_func(function)
88 fn = Path(inspect.getfile(function))
89 lineno = function.__code__.co_firstlineno
90 if curdir is not None:
91 try:
92 relfn = fn.relative_to(curdir)
93 except ValueError:
94 pass
95 else:
96 return "%s:%d" % (relfn, lineno + 1)
97 return "%s:%d" % (fn, lineno + 1)
98
99
100def num_mock_patch_args(function) -> int:

Callers 5

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

Calls 1

get_real_funcFunction · 0.85

Tested by

no test coverage detected