Skip to content

Commit

Permalink
Test for pytest.mark.xfail with non-Python Item
Browse files Browse the repository at this point in the history
  • Loading branch information
vidartf committed Feb 3, 2017
1 parent 1a88a91 commit 832c89d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions testing/test_skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,3 +969,26 @@ def test_func():
result.stdout.fnmatch_lines(
"*Using pytest.skip outside of a test is not allowed*"
)


def test_mark_xfail_item(testdir):
# Ensure pytest.mark.xfail works with non-Python Item
testdir.makeconftest("""
import pytest
class MyItem(pytest.Item):
nodeid = 'foo'
def setup(self):
marker = pytest.mark.xfail(True, reason="Expected failure")
self.add_marker(marker)
def runtest(self):
assert False
def pytest_collect_file(path, parent):
return MyItem("foo", parent)
""")
result = testdir.inline_run()
passed, skipped, failed = result.listoutcomes()
assert not failed
xfailed = [r for r in skipped if hasattr(r, 'wasxfail')]
assert xfailed

0 comments on commit 832c89d

Please sign in to comment.