MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_xfail_item

Function test_xfail_item

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

Source from the content-addressed store, hash-verified

1305
1306
1307def test_xfail_item(pytester: Pytester) -> None:
1308 # Ensure pytest.xfail works with non-Python Item
1309 pytester.makeconftest(
1310 """
1311 import pytest
1312
1313 class MyItem(pytest.Item):
1314 nodeid = 'foo'
1315 def runtest(self):
1316 pytest.xfail("Expected Failure")
1317
1318 def pytest_collect_file(file_path, parent):
1319 return MyItem.from_parent(name="foo", parent=parent)
1320 """
1321 )
1322 result = pytester.inline_run()
1323 passed, skipped, failed = result.listoutcomes()
1324 assert not failed
1325 xfailed = [r for r in skipped if hasattr(r, "wasxfail")]
1326 assert xfailed
1327
1328
1329def 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