MCPcopy
hub / github.com/pytest-dev/pytest / test_xfail_item

Function test_xfail_item

testing/test_skipping.py:1293–1312  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1291
1292
1293def test_xfail_item(pytester: Pytester) -> None:
1294 # Ensure pytest.xfail works with non-Python Item
1295 pytester.makeconftest(
1296 """
1297 import pytest
1298
1299 class MyItem(pytest.Item):
1300 nodeid = 'foo'
1301 def runtest(self):
1302 pytest.xfail("Expected Failure")
1303
1304 def pytest_collect_file(file_path, parent):
1305 return MyItem.from_parent(name="foo", parent=parent)
1306 """
1307 )
1308 result = pytester.inline_run()
1309 _passed, skipped, failed = result.listoutcomes()
1310 assert not failed
1311 xfailed = [r for r in skipped if hasattr(r, "wasxfail")]
1312 assert xfailed
1313
1314
1315def test_module_level_skip_error(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

listoutcomesMethod · 0.80
makeconftestMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected