This commit is contained in:
Michael Aquilina 2015-10-01 22:36:43 +01:00
parent 9e57954b03
commit 213dbe7a5f
2 changed files with 7 additions and 0 deletions

View File

@ -7,12 +7,14 @@ import py
import pytest
from _pytest.mark import MarkInfo
def pytest_addoption(parser):
group = parser.getgroup("general")
group.addoption('--runxfail',
action="store_true", dest="runxfail", default=False,
help="run tests even if they are marked xfail")
def pytest_configure(config):
if config.option.runxfail:
old = pytest.xfail
@ -39,18 +41,22 @@ def pytest_configure(config):
"See http://pytest.org/latest/skipping.html"
)
def pytest_namespace():
return dict(xfail=xfail)
class XFailed(pytest.fail.Exception):
""" raised from an explicit call to pytest.xfail() """
def xfail(reason=""):
""" xfail an executing test or setup functions with the given reason."""
__tracebackhide__ = True
raise XFailed(reason)
xfail.Exception = XFailed
class MarkEvaluator(object):
def __init__(self, item, name):
self.item = item

View File

@ -4,6 +4,7 @@ import sys
from _pytest.skipping import MarkEvaluator, folded_skips, pytest_runtest_setup
from _pytest.runner import runtestprotocol
class TestEvaluator(object):
def test_no_marker(self, testdir):
item = testdir.getitem("def test_func(): pass")