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

Function test_mark_xfail_item

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

Source from the content-addressed store, hash-verified

1374
1375
1376def test_mark_xfail_item(pytester: Pytester) -> None:
1377 # Ensure pytest.mark.xfail works with non-Python Item
1378 pytester.makeconftest(
1379 """
1380 import pytest
1381
1382 class MyItem(pytest.Item):
1383 nodeid = 'foo'
1384 def setup(self):
1385 marker = pytest.mark.xfail("1 == 2", reason="Expected failure - false")
1386 self.add_marker(marker)
1387 marker = pytest.mark.xfail(True, reason="Expected failure - true")
1388 self.add_marker(marker)
1389 def runtest(self):
1390 assert False
1391
1392 def pytest_collect_file(file_path, parent):
1393 return MyItem.from_parent(name="foo", parent=parent)
1394 """
1395 )
1396 result = pytester.inline_run()
1397 passed, skipped, failed = result.listoutcomes()
1398 assert not failed
1399 xfailed = [r for r in skipped if hasattr(r, "wasxfail")]
1400 assert xfailed
1401
1402
1403def 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