Skip to content

Commit 475deb1

Browse files
committed
get_real_func will unwrap the underlying fixture function
1 parent 3ba7108 commit 475deb1

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

src/_pytest/fixtures.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,10 +1242,6 @@ def __init__(
12421242
else:
12431243
self._fixture_function = function
12441244
functools.update_wrapper(self, function)
1245-
# Wrapping the original function will create a __wrapped__ in this object.
1246-
# Remove the __wrapped__ so the inspect.unwrap will not access the original function.
1247-
# Unwrapping must be done with the _get_wrapped_function method.
1248-
delattr(self, "__wrapped__")
12491245

12501246
def __repr__(self) -> str:
12511247
return f"<pytest_fixture({self._fixture_function})>"

testing/test_compat.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ def wrapped_func3():
6767
pass # pragma: no cover
6868

6969
wrapped_func4 = decorator(wrapped_func3)
70-
assert (
71-
# get_real_func does not unwrap function that is wrapped by fixture hence we need to call _get_wrapped_function
72-
get_real_func(wrapped_func4)._get_wrapped_function()
73-
is wrapped_func3._get_wrapped_function()
74-
)
70+
assert get_real_func(wrapped_func4) is wrapped_func3._get_wrapped_function()
7571

7672

7773
def test_get_real_func_partial() -> None:

0 commit comments

Comments
 (0)