Check that get_real_func correctly unwraps decorators until reaching the real function
()
| 57 | |
| 58 | |
| 59 | def 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 | |
| 84 | def test_get_real_func_partial() -> None: |
nothing calls this directly
no test coverage detected