File tree Expand file tree Collapse file tree 2 files changed +5
-18
lines changed
Expand file tree Collapse file tree 2 files changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -214,21 +214,11 @@ def get_real_func(obj):
214214 :func:`functools.wraps`, or :func:`functools.partial`, or :func:`pytest.fixture`."""
215215 from _pytest .fixtures import FixtureFunctionDefinition
216216
217- start_obj = obj
218- for _ in range (100 ):
219- if isinstance (obj , FixtureFunctionDefinition ):
220- obj = obj ._get_wrapped_function ()
221- break
222- new_obj = getattr (obj , "__wrapped__" , None )
223- if new_obj is None :
224- break
225- obj = new_obj
226- else :
227- from _pytest ._io .saferepr import saferepr
217+ obj = inspect .unwrap (obj , stop = lambda x : type (x ) is FixtureFunctionDefinition )
218+
219+ if type (obj ) == FixtureFunctionDefinition :
220+ obj = obj ._get_wrapped_function ()
228221
229- raise ValueError (
230- f"could not find real function of { saferepr (start_obj )} \n stopped at { saferepr (obj )} "
231- )
232222 if isinstance (obj , functools .partial ):
233223 obj = obj .func
234224 return obj
Original file line number Diff line number Diff line change @@ -51,10 +51,7 @@ def __getattr__(self, attr):
5151
5252 with pytest .raises (
5353 ValueError ,
54- match = (
55- "could not find real function of <Evil left=900>\n "
56- "stopped at <Evil left=900>"
57- ),
54+ match = ("wrapper loop when unwrapping <Evil left=998>" ),
5855 ):
5956 get_real_func (evil )
6057
You can’t perform that action at this time.
0 commit comments