parameterset: refactor marking empty parametersets
This commit is contained in:
parent
b8be339632
commit
bf2c10c810
|
@ -73,7 +73,7 @@ class ParameterSet(namedtuple('ParameterSet', 'values, marks, id')):
|
|||
return cls(argval, marks=newmarks, id=None)
|
||||
|
||||
@classmethod
|
||||
def _for_parameterize(cls, argnames, argvalues, function):
|
||||
def _for_parameterize(cls, argnames, argvalues, function, config):
|
||||
if not isinstance(argnames, (tuple, list)):
|
||||
argnames = [x.strip() for x in argnames.split(",") if x.strip()]
|
||||
force_tuple = len(argnames) == 1
|
||||
|
@ -85,10 +85,7 @@ class ParameterSet(namedtuple('ParameterSet', 'values, marks, id')):
|
|||
del argvalues
|
||||
|
||||
if not parameters:
|
||||
fs, lineno = getfslineno(function)
|
||||
reason = "got empty parameter set %r, function %s at %s:%d" % (
|
||||
argnames, function.__name__, fs, lineno)
|
||||
mark = MARK_GEN.skip(reason=reason)
|
||||
mark = get_empty_parameterset_mark(config, argnames, function)
|
||||
parameters.append(ParameterSet(
|
||||
values=(NOTSET,) * len(argnames),
|
||||
marks=[mark],
|
||||
|
@ -97,6 +94,14 @@ class ParameterSet(namedtuple('ParameterSet', 'values, marks, id')):
|
|||
return argnames, parameters
|
||||
|
||||
|
||||
def get_empty_parameterset_mark(config, argnames, function):
|
||||
|
||||
fs, lineno = getfslineno(function)
|
||||
reason = "got empty parameter set %r, function %s at %s:%d" % (
|
||||
argnames, function.__name__, fs, lineno)
|
||||
return MARK_GEN.skip(reason=reason)
|
||||
|
||||
|
||||
class MarkerError(Exception):
|
||||
|
||||
"""Error in use of a pytest marker/attribute."""
|
||||
|
|
|
@ -786,7 +786,7 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):
|
|||
from _pytest.mark import ParameterSet
|
||||
from py.io import saferepr
|
||||
argnames, parameters = ParameterSet._for_parameterize(
|
||||
argnames, argvalues, self.function)
|
||||
argnames, argvalues, self.function, self.config)
|
||||
del argvalues
|
||||
|
||||
if scope is None:
|
||||
|
|
Loading…
Reference in New Issue