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

Function test_mark_xfail_item

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

Source from the content-addressed store, hash-verified

1360
1361
1362def test_mark_xfail_item(pytester: Pytester) -> None:
1363 # Ensure pytest.mark.xfail works with non-Python Item
1364 pytester.makeconftest(
1365 """
1366 import pytest
1367
1368 class MyItem(pytest.Item):
1369 nodeid = 'foo'
1370 def setup(self):
1371 marker = pytest.mark.xfail("1 == 2", reason="Expected failure - false")
1372 self.add_marker(marker)
1373 marker = pytest.mark.xfail(True, reason="Expected failure - true")
1374 self.add_marker(marker)
1375 def runtest(self):
1376 assert False
1377
1378 def pytest_collect_file(file_path, parent):
1379 return MyItem.from_parent(name="foo", parent=parent)
1380 """
1381 )
1382 result = pytester.inline_run()
1383 _passed, skipped, failed = result.listoutcomes()
1384 assert not failed
1385 xfailed = [r for r in skipped if hasattr(r, "wasxfail")]
1386 assert xfailed
1387
1388
1389def test_summary_list_after_errors(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