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

Function get_real_method

src/_pytest/compat.py:296–307  ·  view source on GitHub ↗

Attempt to obtain the real function object that might be wrapping ``obj``, while at the same time returning a bound method to ``holder`` if the original object was a bound method.

(obj, holder)

Source from the content-addressed store, hash-verified

294
295
296def get_real_method(obj, holder):
297 """Attempt to obtain the real function object that might be wrapping
298 ``obj``, while at the same time returning a bound method to ``holder`` if
299 the original object was a bound method."""
300 try:
301 is_method = hasattr(obj, "__func__")
302 obj = get_real_func(obj)
303 except Exception: # pragma: no cover
304 return obj
305 if is_method and hasattr(obj, "__get__") and callable(obj.__get__):
306 obj = obj.__get__(holder)
307 return obj
308
309
310def getimfunc(func):

Callers 1

parsefactoriesMethod · 0.90

Calls 2

get_real_funcFunction · 0.85
__get__Method · 0.80

Tested by

no test coverage detected