Ensure Class.from_parent can forward custom arguments to the constructor.
(request: FixtureRequest)
| 1609 | |
| 1610 | |
| 1611 | def test_class_from_parent(request: FixtureRequest) -> None: |
| 1612 | """Ensure Class.from_parent can forward custom arguments to the constructor.""" |
| 1613 | |
| 1614 | class MyCollector(pytest.Class): |
| 1615 | def __init__(self, name, parent, x): |
| 1616 | super().__init__(name, parent) |
| 1617 | self.x = x |
| 1618 | |
| 1619 | @classmethod |
| 1620 | def from_parent(cls, parent, *, name, x): # type: ignore[override] |
| 1621 | return super().from_parent(parent=parent, name=name, x=x) |
| 1622 | |
| 1623 | collector = MyCollector.from_parent(parent=request.session, name="foo", x=10) |
| 1624 | assert collector.x == 10 |
| 1625 | |
| 1626 | |
| 1627 | class TestImportModeImportlib: |
nothing calls this directly
no test coverage detected