@@ -899,15 +899,10 @@ def __repr__(self):
899
899
)
900
900
901
901
902
- def pytest_fixture_setup (fixturedef , request ):
903
- """ Execution of fixture setup. """
904
- kwargs = {}
905
- for argname in fixturedef .argnames :
906
- fixdef = request ._get_active_fixturedef (argname )
907
- result , arg_cache_key , exc = fixdef .cached_result
908
- request ._check_scope (argname , request .scope , fixdef .scope )
909
- kwargs [argname ] = result
910
-
902
+ def resolve_fixture_function (fixturedef , request ):
903
+ """Gets the actual callable that can be called to obtain the fixture value, dealing with unittest-specific
904
+ instances and bound methods.
905
+ """
911
906
fixturefunc = fixturedef .func
912
907
if fixturedef .unittest :
913
908
if request .instance is not None :
@@ -921,6 +916,19 @@ def pytest_fixture_setup(fixturedef, request):
921
916
fixturefunc = getimfunc (fixturedef .func )
922
917
if fixturefunc != fixturedef .func :
923
918
fixturefunc = fixturefunc .__get__ (request .instance )
919
+ return fixturefunc
920
+
921
+
922
+ def pytest_fixture_setup (fixturedef , request ):
923
+ """ Execution of fixture setup. """
924
+ kwargs = {}
925
+ for argname in fixturedef .argnames :
926
+ fixdef = request ._get_active_fixturedef (argname )
927
+ result , arg_cache_key , exc = fixdef .cached_result
928
+ request ._check_scope (argname , request .scope , fixdef .scope )
929
+ kwargs [argname ] = result
930
+
931
+ fixturefunc = resolve_fixture_function (fixturedef , request )
924
932
my_cache_key = request .param_index
925
933
try :
926
934
result = call_fixture_func (fixturefunc , request , kwargs )
0 commit comments