File tree 1 file changed +23
-0
lines changed 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -969,3 +969,26 @@ def test_func():
969
969
result .stdout .fnmatch_lines (
970
970
"*Using pytest.skip outside of a test is not allowed*"
971
971
)
972
+
973
+
974
+ def test_mark_xfail_item (testdir ):
975
+ # Ensure pytest.mark.xfail works with non-Python Item
976
+ testdir .makeconftest ("""
977
+ import pytest
978
+
979
+ class MyItem(pytest.Item):
980
+ nodeid = 'foo'
981
+ def setup(self):
982
+ marker = pytest.mark.xfail(True, reason="Expected failure")
983
+ self.add_marker(marker)
984
+ def runtest(self):
985
+ assert False
986
+
987
+ def pytest_collect_file(path, parent):
988
+ return MyItem("foo", parent)
989
+ """ )
990
+ result = testdir .inline_run ()
991
+ passed , skipped , failed = result .listoutcomes ()
992
+ assert not failed
993
+ xfailed = [r for r in skipped if hasattr (r , 'wasxfail' )]
994
+ assert xfailed
You can’t perform that action at this time.
0 commit comments