diff --git a/_pytest/skipping.py b/_pytest/skipping.py index 491dd66a9..c3b7f7b77 100644 --- a/_pytest/skipping.py +++ b/_pytest/skipping.py @@ -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 diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 05e0683c5..f9cf9354f 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -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")