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

Function test_fancy_items_regression

testing/test_junitxml.py:1413–1462  ·  view source on GitHub ↗
(pytester: Pytester, run_and_parse: RunAndParse)

Source from the content-addressed store, hash-verified

1411
1412
1413def test_fancy_items_regression(pytester: Pytester, run_and_parse: RunAndParse) -> None:
1414 # issue 1259
1415 pytester.makeconftest(
1416 """
1417 import pytest
1418 class FunItem(pytest.Item):
1419 def runtest(self):
1420 pass
1421 class NoFunItem(pytest.Item):
1422 def runtest(self):
1423 pass
1424
1425 class FunCollector(pytest.File):
1426 def collect(self):
1427 return [
1428 FunItem.from_parent(name='a', parent=self),
1429 NoFunItem.from_parent(name='a', parent=self),
1430 NoFunItem.from_parent(name='b', parent=self),
1431 ]
1432
1433 def pytest_collect_file(file_path, parent):
1434 if file_path.suffix == '.py':
1435 return FunCollector.from_parent(path=file_path, parent=parent)
1436 """
1437 )
1438
1439 pytester.makepyfile(
1440 """
1441 def test_pass():
1442 pass
1443 """
1444 )
1445
1446 result, dom = run_and_parse()
1447
1448 result.stdout.no_fnmatch_line("*INTERNALERROR*")
1449
1450 items = sorted("%(classname)s %(name)s" % x for x in dom.find_by_tag("testcase"))
1451 import pprint
1452
1453 pprint.pprint(items)
1454 assert items == [
1455 "conftest a",
1456 "conftest a",
1457 "conftest b",
1458 "test_fancy_items_regression a",
1459 "test_fancy_items_regression a",
1460 "test_fancy_items_regression b",
1461 "test_fancy_items_regression test_pass",
1462 ]
1463
1464
1465@parametrize_families

Callers

nothing calls this directly

Calls 5

run_and_parseFunction · 0.85
no_fnmatch_lineMethod · 0.80
find_by_tagMethod · 0.80
makeconftestMethod · 0.45
makepyfileMethod · 0.45

Tested by

no test coverage detected