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

Function test_get_real_func

testing/test_compat.py:43–68  ·  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

41
42
43def test_get_real_func() -> None:
44 """Check that get_real_func correctly unwraps decorators until reaching the real function"""
45
46 def decorator(f):
47 @wraps(f)
48 def inner():
49 pass # pragma: no cover
50
51 return inner
52
53 def func():
54 pass # pragma: no cover
55
56 wrapped_func = decorator(decorator(func))
57 assert get_real_func(wrapped_func) is func
58
59 wrapped_func2 = decorator(decorator(wrapped_func))
60 assert get_real_func(wrapped_func2) is func
61
62 # obtain the function up until the point a function was wrapped by pytest itself
63 @pytest.fixture
64 def wrapped_func3():
65 pass # pragma: no cover
66
67 wrapped_func4 = decorator(wrapped_func3)
68 assert get_real_func(wrapped_func4) is wrapped_func3._get_wrapped_function()
69
70
71def test_get_real_func_partial() -> None:

Callers

nothing calls this directly

Calls 3

get_real_funcFunction · 0.90
_get_wrapped_functionMethod · 0.80
decoratorFunction · 0.70

Tested by

no test coverage detected