diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-02-23 17:56:42 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-02-23 18:00:56 +0100 |
commit | 54a154c86f4806327081b80193cebca7934468d0 (patch) | |
tree | 2fbe41332debbca355f77cbc76ee42cc6f37af9d /src/_pytest | |
parent | d6522b517bceca2c8f7be1a34a3efd7d741a3132 (diff) | |
download | pytest-54a154c86f4806327081b80193cebca7934468d0.tar.gz |
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.
Diffstat (limited to 'src/_pytest')
-rw-r--r-- | src/_pytest/python.py | 4 |
1 files changed, 2 insertions, 2 deletions
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): |