From 0d0b01bded8ab758118d9be1ea64db493045dcf4 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Fri, 23 Jun 2017 21:06:18 +0200 Subject: [PATCH] introduce deprecation warnings for legacy parametersets, fixes #2427 --- _pytest/deprecated.py | 6 ++++++ _pytest/mark.py | 5 ++++- changelog/2427.removal | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelog/2427.removal diff --git a/_pytest/deprecated.py b/_pytest/deprecated.py index c5aedd0c9..1eeb74918 100644 --- a/_pytest/deprecated.py +++ b/_pytest/deprecated.py @@ -30,4 +30,10 @@ RESULT_LOG = '--result-log is deprecated and scheduled for removal in pytest 4.0 MARK_INFO_ATTRIBUTE = RemovedInPytest4Warning( "MarkInfo objects are deprecated as they contain the merged marks" +) + +MARK_PARAMETERSET_UNPACKING = RemovedInPytest4Warning( + "Applying marks directly to parameters is deprecated," + " please use pytest.param(..., marks=...) instead.\n" + "For more details, see: https://docs.pytest.org/en/latest/parametrize.html" ) \ No newline at end of file diff --git a/_pytest/mark.py b/_pytest/mark.py index 11f1e30d6..961c3c409 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -6,7 +6,7 @@ import warnings from collections import namedtuple from operator import attrgetter from .compat import imap -from .deprecated import MARK_INFO_ATTRIBUTE +from .deprecated import MARK_INFO_ATTRIBUTE, MARK_PARAMETERSET_UNPACKING def alias(name, warning=None): getter = attrgetter(name) @@ -61,6 +61,9 @@ class ParameterSet(namedtuple('ParameterSet', 'values, marks, id')): if legacy_force_tuple: argval = argval, + if newmarks: + warnings.warn(MARK_PARAMETERSET_UNPACKING) + return cls(argval, marks=newmarks, id=None) @property diff --git a/changelog/2427.removal b/changelog/2427.removal new file mode 100644 index 000000000..c7ed8e17a --- /dev/null +++ b/changelog/2427.removal @@ -0,0 +1 @@ +introduce deprecation warnings for legacy marks based parametersets