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

Function test_get_real_func

testing/test_compat.py:59–81  ·  view source on GitHub ↗

Check that get_real_func correctly unwraps decorators until reaching the real function

()

Source from the content-addressed store, hash-verified

57
58
59def test_get_real_func() -> None:
60 """Check that get_real_func correctly unwraps decorators until reaching the real function"""
61
62 def decorator(f):
63 @wraps(f)
64 def inner():
65 pass # pragma: no cover
66
67 return inner
68
69 def func():
70 pass # pragma: no cover
71
72 wrapped_func = decorator(decorator(func))
73 assert get_real_func(wrapped_func) is func
74
75 wrapped_func2 = decorator(decorator(wrapped_func))
76 assert get_real_func(wrapped_func2) is func
77
78 # special case for __pytest_wrapped__ attribute: used to obtain the function up until the point
79 # a function was wrapped by pytest itself
80 wrapped_func2.__pytest_wrapped__ = _PytestWrapper(wrapped_func)
81 assert get_real_func(wrapped_func2) is wrapped_func
82
83
84def test_get_real_func_partial() -> None:

Callers

nothing calls this directly

Calls 3

get_real_funcFunction · 0.90
_PytestWrapperClass · 0.90
decoratorFunction · 0.85

Tested by

no test coverage detected