From bf2c10c8105d770354d0abc451de4ffd9b986562 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 17 Dec 2017 11:26:51 +0100 Subject: [PATCH] parameterset: refactor marking empty parametersets --- _pytest/mark.py | 15 ++++++++++----- _pytest/python.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/_pytest/mark.py b/_pytest/mark.py index 45182bdcd..35cb3224a 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -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.""" diff --git a/_pytest/python.py b/_pytest/python.py index 735489e48..2a84677ec 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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: