diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 75eac7db6ae..6d7f150c27b 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -217,7 +217,7 @@ def __init__(self, name, parent, runner=None, dtest=None): @classmethod def from_parent(cls, parent, *, name, runner, dtest): - return cls._create(name=name, parent=parent, runner=runner, dtest=dtest) + return super().from_parent(name=name, parent=parent, runner=runner, dtest=dtest) def setup(self): if self.dtest is not None: diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 3eaafa91d5a..f947492f66f 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -144,8 +144,10 @@ def __init__( self._nodeid += "::" + self.name @classmethod - def from_parent(cls, parent, *, name): - return cls._create(parent=parent, name=name) + def from_parent(cls, parent, **kw): + assert "config" not in kw + assert "session" not in kw + return cls._create(parent=parent, **kw) @property def ihook(self): @@ -434,7 +436,7 @@ def __init__( @classmethod def from_parent(cls, parent, *, fspath): - return cls._create(parent=parent, fspath=fspath) + return super().from_parent(parent=parent, fspath=fspath) class File(FSCollector): diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 1b01f4faaef..d26c0de7b22 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -679,7 +679,7 @@ class Class(PyCollector): @classmethod def from_parent(cls, parent, *, name, obj=None): - return cls._create(name=name, parent=parent) + return super().from_parent(name=name, parent=parent) def collect(self): if not safe_getattr(self.obj, "__test__", True): @@ -1459,7 +1459,7 @@ def __init__( @classmethod def from_parent(cls, parent, **kw): - return cls._create(parent=parent, **kw) + return super().from_parent(parent=parent, **kw) def _initrequest(self): self.funcargs = {} diff --git a/testing/python/collect.py b/testing/python/collect.py index 9ac1c9d311c..93e3de42455 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -284,7 +284,7 @@ def make_function(testdir, **kwargs): session = testdir.Session.from_config(config) session._fixturemanager = FixtureManager(session) - return pytest.Function.from_parent(config=config, parent=session, **kwargs) + return pytest.Function.from_parent(parent=session, **kwargs) def test_function_equality(self, testdir, tmpdir): def func1():