From b3a981d3859f563fa6c24d8a30e1bf76030d2968 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 8 Sep 2023 10:23:14 +0300 Subject: [PATCH] fixtures: remove `getfixtureinfo(funcargs)` in favor of None `func` Since we already broke plugins using this (private) interface in this version (pytest-play, pytest-wdl), might as well do a cleanup. --- src/_pytest/doctest.py | 7 +------ src/_pytest/fixtures.py | 9 +++------ src/_pytest/python.py | 5 ++--- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 46a3daa72..97aa5d3dd 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -592,14 +592,9 @@ class DoctestModule(Module): def _setup_fixtures(doctest_item: DoctestItem) -> TopRequest: """Used by DoctestTextfile and DoctestItem to setup fixture information.""" - def func() -> None: - pass - doctest_item.funcargs = {} # type: ignore[attr-defined] fm = doctest_item.session._fixturemanager - fixtureinfo = fm.getfixtureinfo( - node=doctest_item, func=func, cls=None, funcargs=False - ) + fixtureinfo = fm.getfixtureinfo(node=doctest_item, func=None, cls=None) doctest_item._fixtureinfo = fixtureinfo # type: ignore[attr-defined] doctest_item.fixturenames = fixtureinfo.names_closure # type: ignore[attr-defined] fixture_request = TopRequest(doctest_item, _ispytest=True) # type: ignore[arg-type] diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 80b965b81..d56274629 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1460,13 +1460,12 @@ class FixtureManager: def getfixtureinfo( self, node: nodes.Item, - func: Callable[..., object], + func: Optional[Callable[..., object]], cls: Optional[type], - funcargs: bool = True, ) -> FuncFixtureInfo: """Calculate the :class:`FuncFixtureInfo` for an item. - If ``funcargs`` is false, or if the item sets an attribute + If ``func`` is None, or if the item sets an attribute ``nofuncargs = True``, then ``func`` is not examined at all. :param node: @@ -1475,10 +1474,8 @@ class FixtureManager: The item's function. :param cls: If the function is a method, the method's class. - :param funcargs: - Whether to look into func's parameters as fixture requests. """ - if funcargs and not getattr(node, "nofuncargs", False): + if func is not None and not getattr(node, "nofuncargs", False): argnames = getfuncargnames(func, name=node.name, cls=cls) else: argnames = () diff --git a/src/_pytest/python.py b/src/_pytest/python.py index e8d55c929..cbb82e390 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1800,9 +1800,8 @@ class Function(PyobjMixin, nodes.Item): self.keywords.update(keywords) if fixtureinfo is None: - fixtureinfo = self.session._fixturemanager.getfixtureinfo( - self, self.obj, self.cls, funcargs=True - ) + fm = self.session._fixturemanager + fixtureinfo = fm.getfixtureinfo(self, self.obj, self.cls) self._fixtureinfo: FuncFixtureInfo = fixtureinfo self.fixturenames = fixtureinfo.names_closure self._initrequest()