Check that param sets match number of args during _for_parametrize
It makes sense to validate them during creation of the parameter set
This commit is contained in:
parent
54fbc6f6e1
commit
3e599dc149
|
@ -111,7 +111,19 @@ class ParameterSet(namedtuple("ParameterSet", "values, marks, id")):
|
||||||
]
|
]
|
||||||
del argvalues
|
del argvalues
|
||||||
|
|
||||||
if not parameters:
|
if parameters:
|
||||||
|
# check all parameter sets have the correct number of values
|
||||||
|
for param in parameters:
|
||||||
|
if len(param.values) != len(argnames):
|
||||||
|
raise ValueError(
|
||||||
|
'In "parametrize" the number of values ({}) must be '
|
||||||
|
"equal to the number of names ({})".format(
|
||||||
|
param.values, argnames
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# empty parameter set (likely computed at runtime): create a single
|
||||||
|
# parameter set with NOSET values, with the "empty parameter set" mark applied to it
|
||||||
mark = get_empty_parameterset_mark(config, argnames, func)
|
mark = get_empty_parameterset_mark(config, argnames, func)
|
||||||
parameters.append(
|
parameters.append(
|
||||||
ParameterSet(values=(NOTSET,) * len(argnames), marks=[mark], id=None)
|
ParameterSet(values=(NOTSET,) * len(argnames), marks=[mark], id=None)
|
||||||
|
|
|
@ -8,7 +8,6 @@ import os
|
||||||
import collections
|
import collections
|
||||||
import warnings
|
import warnings
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from itertools import count
|
|
||||||
|
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
@ -887,22 +886,14 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):
|
||||||
# of all calls
|
# of all calls
|
||||||
newcalls = []
|
newcalls = []
|
||||||
for callspec in self._calls or [CallSpec2(self)]:
|
for callspec in self._calls or [CallSpec2(self)]:
|
||||||
elements = zip(ids, parameters, count())
|
for param_index, (param_id, param_set) in enumerate(zip(ids, parameters)):
|
||||||
for a_id, param, param_index in elements:
|
|
||||||
if len(param.values) != len(argnames):
|
|
||||||
raise ValueError(
|
|
||||||
'In "parametrize" the number of values ({}) must be '
|
|
||||||
"equal to the number of names ({})".format(
|
|
||||||
param.values, argnames
|
|
||||||
)
|
|
||||||
)
|
|
||||||
newcallspec = callspec.copy()
|
newcallspec = callspec.copy()
|
||||||
newcallspec.setmulti2(
|
newcallspec.setmulti2(
|
||||||
arg_values_types,
|
arg_values_types,
|
||||||
argnames,
|
argnames,
|
||||||
param.values,
|
param_set.values,
|
||||||
a_id,
|
param_id,
|
||||||
param.marks,
|
param_set.marks,
|
||||||
scopenum,
|
scopenum,
|
||||||
param_index,
|
param_index,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue