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