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

Function test_fscollector_from_parent

testing/test_collection.py:1591–1608  ·  view source on GitHub ↗

Ensure File.from_parent can forward custom arguments to the constructor. Context: https://github.com/pytest-dev/pytest-cpp/pull/47

(pytester: Pytester, request: FixtureRequest)

Source from the content-addressed store, hash-verified

1589
1590
1591def test_fscollector_from_parent(pytester: Pytester, request: FixtureRequest) -> None:
1592 """Ensure File.from_parent can forward custom arguments to the constructor.
1593
1594 Context: https://github.com/pytest-dev/pytest-cpp/pull/47
1595 """
1596
1597 class MyCollector(pytest.File):
1598 def __init__(self, *k, x, **kw):
1599 super().__init__(*k, **kw)
1600 self.x = x
1601
1602 def collect(self):
1603 raise NotImplementedError()
1604
1605 collector = MyCollector.from_parent(
1606 parent=request.session, path=pytester.path / "foo", x=10
1607 )
1608 assert collector.x == 10
1609
1610
1611def test_class_from_parent(request: FixtureRequest) -> None:

Callers

nothing calls this directly

Calls 1

from_parentMethod · 0.45

Tested by

no test coverage detected