port mark evaluation to the new storage and fix a bug in evaluation
This commit is contained in:
parent
360d608da4
commit
2707221559
|
@ -371,10 +371,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
|
||||||
:arg marker: a :py:class:`_pytest.mark.MarkDecorator` object
|
:arg marker: a :py:class:`_pytest.mark.MarkDecorator` object
|
||||||
created by a call to ``pytest.mark.NAME(...)``.
|
created by a call to ``pytest.mark.NAME(...)``.
|
||||||
"""
|
"""
|
||||||
try:
|
self.node.add_marker(marker)
|
||||||
self.node.keywords[marker.markname] = marker
|
|
||||||
except AttributeError:
|
|
||||||
raise ValueError(marker)
|
|
||||||
|
|
||||||
def raiseerror(self, msg):
|
def raiseerror(self, msg):
|
||||||
""" raise a FixtureLookupError with the given message. """
|
""" raise a FixtureLookupError with the given message. """
|
||||||
|
|
|
@ -4,7 +4,6 @@ import sys
|
||||||
import platform
|
import platform
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from . import MarkDecorator, MarkInfo
|
|
||||||
from ..outcomes import fail, TEST_OUTCOME
|
from ..outcomes import fail, TEST_OUTCOME
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ class MarkEvaluator(object):
|
||||||
self._mark_name = name
|
self._mark_name = name
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
self._marks = self._get_marks()
|
|
||||||
return bool(self._marks)
|
return bool(self._marks)
|
||||||
__nonzero__ = __bool__
|
__nonzero__ = __bool__
|
||||||
|
|
||||||
|
@ -36,14 +34,7 @@ class MarkEvaluator(object):
|
||||||
return not hasattr(self, 'exc')
|
return not hasattr(self, 'exc')
|
||||||
|
|
||||||
def _get_marks(self):
|
def _get_marks(self):
|
||||||
|
return list(self.item.find_markers(self._mark_name))
|
||||||
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 []
|
|
||||||
|
|
||||||
def invalidraise(self, exc):
|
def invalidraise(self, exc):
|
||||||
raises = self.get('raises')
|
raises = self.get('raises')
|
||||||
|
|
|
@ -715,7 +715,6 @@ class TestFunctional(object):
|
||||||
if isinstance(v, MarkInfo)])
|
if isinstance(v, MarkInfo)])
|
||||||
assert marker_names == set(expected_markers)
|
assert marker_names == set(expected_markers)
|
||||||
|
|
||||||
@pytest.mark.xfail(reason='callspec2.setmulti misuses keywords')
|
|
||||||
@pytest.mark.issue1540
|
@pytest.mark.issue1540
|
||||||
def test_mark_from_parameters(self, testdir):
|
def test_mark_from_parameters(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
|
|
Loading…
Reference in New Issue