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)
| 1589 | |
| 1590 | |
| 1591 | def 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 | |
| 1611 | def test_class_from_parent(request: FixtureRequest) -> None: |
nothing calls this directly
no test coverage detected