From 54a154c86f4806327081b80193cebca7934468d0 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 23 Feb 2021 17:56:42 +0100 Subject: Allow Class.from_parent to forward custom parameters to the constructor Similarly to #7143, at work we have a project with a custom pytest.Class subclass, adding an additional argument to the constructor. All from_parent implementations in pytest accept and forward *kw, except Class (before this change) and DoctestItem - since I'm not familiar with doctest support, I've left the latter as-is. --- src/_pytest/python.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/_pytest') diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 726241cb5..944c395a8 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -763,9 +763,9 @@ class Class(PyCollector): """Collector for test methods.""" @classmethod - def from_parent(cls, parent, *, name, obj=None): + def from_parent(cls, parent, *, name, obj=None, **kw): """The public constructor.""" - return super().from_parent(name=name, parent=parent) + return super().from_parent(name=name, parent=parent, **kw) def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]: if not safe_getattr(self.obj, "__test__", True): -- cgit v1.2.3