From 27072215593b2808bbae2fb633caf556cc5852e3 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Fri, 16 Mar 2018 11:16:08 +0100 Subject: [PATCH] port mark evaluation to the new storage and fix a bug in evaluation --- _pytest/fixtures.py | 5 +---- _pytest/mark/evaluate.py | 11 +---------- testing/test_mark.py | 1 - 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index 2ac340e6f..5c6a4a230 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -371,10 +371,7 @@ class FixtureRequest(FuncargnamesCompatAttr): :arg marker: a :py:class:`_pytest.mark.MarkDecorator` object created by a call to ``pytest.mark.NAME(...)``. """ - try: - self.node.keywords[marker.markname] = marker - except AttributeError: - raise ValueError(marker) + self.node.add_marker(marker) def raiseerror(self, msg): """ raise a FixtureLookupError with the given message. """ diff --git a/_pytest/mark/evaluate.py b/_pytest/mark/evaluate.py index 295373e17..1aef138b1 100644 --- a/_pytest/mark/evaluate.py +++ b/_pytest/mark/evaluate.py @@ -4,7 +4,6 @@ import sys import platform import traceback -from . import MarkDecorator, MarkInfo from ..outcomes import fail, TEST_OUTCOME @@ -28,7 +27,6 @@ class MarkEvaluator(object): self._mark_name = name def __bool__(self): - self._marks = self._get_marks() return bool(self._marks) __nonzero__ = __bool__ @@ -36,14 +34,7 @@ class MarkEvaluator(object): return not hasattr(self, 'exc') def _get_marks(self): - - keyword = self.item.keywords.get(self._mark_name) - if isinstance(keyword, MarkDecorator): - return [keyword.mark] - elif isinstance(keyword, MarkInfo): - return [x.combined for x in keyword] - else: - return [] + return list(self.item.find_markers(self._mark_name)) def invalidraise(self, exc): raises = self.get('raises') diff --git a/testing/test_mark.py b/testing/test_mark.py index b4dd65634..95e391a0c 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -715,7 +715,6 @@ class TestFunctional(object): if isinstance(v, MarkInfo)]) assert marker_names == set(expected_markers) - @pytest.mark.xfail(reason='callspec2.setmulti misuses keywords') @pytest.mark.issue1540 def test_mark_from_parameters(self, testdir): testdir.makepyfile("""