@@ -1127,18 +1127,40 @@ def __init__(self, session):
11271127 self ._nodeid_and_autousenames = [("" , self .config .getini ("usefixtures" ))]
11281128 session .config .pluginmanager .register (self , "funcmanage" )
11291129
1130+ def _get_direct_parametrize_args (self , node ):
1131+ """This function returns all the direct parametrization
1132+ arguments of a node, so we don't mistake them for fixtures
1133+
1134+ Check https://github.com/pytest-dev/pytest/issues/5036
1135+
1136+ This things are done later as well when dealing with parametrization
1137+ so this could be improved
1138+ """
1139+ from _pytest .mark import ParameterSet
1140+
1141+ parametrize_argnames = []
1142+ for marker in node .iter_markers (name = "parametrize" ):
1143+ if not marker .kwargs .get ("indirect" , False ):
1144+ p_argnames , _ = ParameterSet ._parse_parametrize_args (
1145+ * marker .args , ** marker .kwargs
1146+ )
1147+ parametrize_argnames .extend (p_argnames )
1148+
1149+ return parametrize_argnames
1150+
11301151 def getfixtureinfo (self , node , func , cls , funcargs = True ):
11311152 if funcargs and not getattr (node , "nofuncargs" , False ):
11321153 argnames = getfuncargnames (func , cls = cls )
11331154 else :
11341155 argnames = ()
1156+
11351157 usefixtures = itertools .chain .from_iterable (
11361158 mark .args for mark in node .iter_markers (name = "usefixtures" )
11371159 )
11381160 initialnames = tuple (usefixtures ) + argnames
11391161 fm = node .session ._fixturemanager
11401162 initialnames , names_closure , arg2fixturedefs = fm .getfixtureclosure (
1141- initialnames , node
1163+ initialnames , node , ignore_args = self . _get_direct_parametrize_args ( node )
11421164 )
11431165 return FuncFixtureInfo (argnames , initialnames , names_closure , arg2fixturedefs )
11441166
@@ -1172,7 +1194,7 @@ def _getautousenames(self, nodeid):
11721194 autousenames .extend (basenames )
11731195 return autousenames
11741196
1175- def getfixtureclosure (self , fixturenames , parentnode ):
1197+ def getfixtureclosure (self , fixturenames , parentnode , ignore_args = () ):
11761198 # collect the closure of all fixtures , starting with the given
11771199 # fixturenames as the initial set. As we have to visit all
11781200 # factory definitions anyway, we also return an arg2fixturedefs
@@ -1200,6 +1222,8 @@ def merge(otherlist):
12001222 while lastlen != len (fixturenames_closure ):
12011223 lastlen = len (fixturenames_closure )
12021224 for argname in fixturenames_closure :
1225+ if argname in ignore_args :
1226+ continue
12031227 if argname in arg2fixturedefs :
12041228 continue
12051229 fixturedefs = self .getfixturedefs (argname , parentid )
0 commit comments