From 0b0e2d2dbb59ad20c7e70691dec56fc5e2b1047c Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 7 Dec 2021 21:56:46 +0200 Subject: [PATCH] Remove deprecated `_fillfuncargs` function --- doc/en/deprecations.rst | 14 ++++--- doc/en/how-to/plugins.rst | 3 -- src/_pytest/deprecated.py | 6 --- src/_pytest/fixtures.py | 37 ------------------ src/pytest/__init__.py | 2 - src/pytest/collect.py | 1 - testing/deprecated_test.py | 25 ------------ testing/python/fixtures.py | 4 -- testing/python/integration.py | 74 ----------------------------------- 9 files changed, 8 insertions(+), 158 deletions(-) diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index bcd13fd5b..c0f32c3bc 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -269,10 +269,18 @@ The ``pytest.collect`` module is no longer part of the public API, all its names should now be imported from ``pytest`` directly instead. +Removed Features +---------------- + +As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after +an appropriate period of deprecation has passed. + + The ``pytest._fillfuncargs`` function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. deprecated:: 6.0 +.. versionremoved:: 7.0 This function was kept for backward compatibility with an older plugin. @@ -281,12 +289,6 @@ it, use `function._request._fillfixtures()` instead, though note this is not a public API and may break in the future. -Removed Features ----------------- - -As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after -an appropriate period of deprecation has passed. - ``--no-print-logs`` command-line option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/en/how-to/plugins.rst b/doc/en/how-to/plugins.rst index cae737e96..de31bc04a 100644 --- a/doc/en/how-to/plugins.rst +++ b/doc/en/how-to/plugins.rst @@ -51,9 +51,6 @@ Here is a little annotated list for some popular plugins: * :pypi:`pytest-flakes`: check source code with pyflakes. -* :pypi:`oejskit`: - a plugin to run javascript unittests in live browsers. - To see a complete list of all plugins with their latest testing status against different pytest and Python versions, please visit :ref:`plugin-list`. diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index 5f1edd607..88114fbf3 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -24,12 +24,6 @@ DEPRECATED_EXTERNAL_PLUGINS = { } -FILLFUNCARGS = UnformattedWarning( - PytestRemovedIn7Warning, - "{name} is deprecated, use " - "function._request._fillfixtures() instead if you cannot avoid reaching into internals.", -) - PYTEST_COLLECT_MODULE = UnformattedWarning( PytestRemovedIn7Warning, "pytest.collect.{name} was moved to pytest.{name}\n" diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index fddff931c..e0409fcf2 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -52,7 +52,6 @@ from _pytest.config import _PluggyPlugin from _pytest.config import Config from _pytest.config.argparsing import Parser from _pytest.deprecated import check_ispytest -from _pytest.deprecated import FILLFUNCARGS from _pytest.deprecated import YIELD_FIXTURE from _pytest.mark import Mark from _pytest.mark import ParameterSet @@ -73,7 +72,6 @@ if TYPE_CHECKING: from _pytest.scope import _ScopeName from _pytest.main import Session from _pytest.python import CallSpec2 - from _pytest.python import Function from _pytest.python import Metafunc @@ -352,41 +350,6 @@ def reorder_items_atscope( return items_done -def _fillfuncargs(function: "Function") -> None: - """Fill missing fixtures for a test function, old public API (deprecated).""" - warnings.warn(FILLFUNCARGS.format(name="pytest._fillfuncargs()"), stacklevel=2) - _fill_fixtures_impl(function) - - -def fillfixtures(function: "Function") -> None: - """Fill missing fixtures for a test function (deprecated).""" - warnings.warn( - FILLFUNCARGS.format(name="_pytest.fixtures.fillfixtures()"), stacklevel=2 - ) - _fill_fixtures_impl(function) - - -def _fill_fixtures_impl(function: "Function") -> None: - """Internal implementation to fill fixtures on the given function object.""" - try: - request = function._request - except AttributeError: - # XXX this special code path is only expected to execute - # with the oejskit plugin. It uses classes with funcargs - # and we thus have to work a bit to allow this. - fm = function.session._fixturemanager - assert function.parent is not None - fi = fm.getfixtureinfo(function.parent, function.obj, None) - function._fixtureinfo = fi - request = function._request = FixtureRequest(function, _ispytest=True) - fm.session._setupstate.setup(function) - request._fillfixtures() - # Prune out funcargs for jstests. - function.funcargs = {name: function.funcargs[name] for name in fi.argnames} - else: - request._fillfixtures() - - def get_direct_param_fixture_func(request): return request.param diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index 7a596cd37..26b87c7f5 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -19,7 +19,6 @@ from _pytest.config import UsageError from _pytest.config.argparsing import OptionGroup from _pytest.config.argparsing import Parser from _pytest.debugging import pytestPDB as __pytestPDB -from _pytest.fixtures import _fillfuncargs from _pytest.fixtures import fixture from _pytest.fixtures import FixtureLookupError from _pytest.fixtures import FixtureRequest @@ -81,7 +80,6 @@ set_trace = __pytestPDB.set_trace __all__ = [ "__version__", - "_fillfuncargs", "approx", "Cache", "CallInfo", diff --git a/src/pytest/collect.py b/src/pytest/collect.py index 4b2b58180..71afe5d9c 100644 --- a/src/pytest/collect.py +++ b/src/pytest/collect.py @@ -15,7 +15,6 @@ COLLECT_FAKEMODULE_ATTRIBUTES = [ "Item", "Class", "File", - "_fillfuncargs", ] diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index 7d7e6d312..e4dcfa67f 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -2,7 +2,6 @@ import re import sys import warnings from pathlib import Path -from unittest import mock import pytest from _pytest import deprecated @@ -28,30 +27,6 @@ def test_external_plugins_integrated(pytester: Pytester, plugin) -> None: pytester.parseconfig("-p", plugin) -def test_fillfuncargs_is_deprecated() -> None: - with pytest.warns( - pytest.PytestDeprecationWarning, - match=re.escape( - "pytest._fillfuncargs() is deprecated, use " - "function._request._fillfixtures() instead if you cannot avoid reaching into internals." - ), - ): - pytest._fillfuncargs(mock.Mock()) - - -def test_fillfixtures_is_deprecated() -> None: - import _pytest.fixtures - - with pytest.warns( - pytest.PytestDeprecationWarning, - match=re.escape( - "_pytest.fixtures.fillfixtures() is deprecated, use " - "function._request._fillfixtures() instead if you cannot avoid reaching into internals." - ), - ): - _pytest.fixtures.fillfixtures(mock.Mock()) - - def test_minus_k_dash_is_deprecated(pytester: Pytester) -> None: threepass = pytester.makepyfile( test_threepass=""" diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index f29ca1dfa..3ce5cb34d 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -103,10 +103,6 @@ def test_getfuncargnames_staticmethod_partial(): @pytest.mark.pytester_example_path("fixtures/fill_fixtures") class TestFillFixtures: - def test_fillfuncargs_exposed(self): - # used by oejskit, kept for compatibility - assert pytest._fillfuncargs == fixtures._fillfuncargs - def test_funcarg_lookupfails(self, pytester: Pytester) -> None: pytester.copy_example() result = pytester.runpytest() # "--collect-only") diff --git a/testing/python/integration.py b/testing/python/integration.py index d138b7266..6b5c53c98 100644 --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -1,84 +1,10 @@ -from typing import Any - import pytest -from _pytest import runner from _pytest._code import getfslineno from _pytest.fixtures import getfixturemarker from _pytest.pytester import Pytester from _pytest.python import Function -class TestOEJSKITSpecials: - def test_funcarg_non_pycollectobj( - self, pytester: Pytester, recwarn - ) -> None: # rough jstests usage - pytester.makeconftest( - """ - import pytest - def pytest_pycollect_makeitem(collector, name, obj): - if name == "MyClass": - return MyCollector.from_parent(collector, name=name) - class MyCollector(pytest.Collector): - def reportinfo(self): - return self.path, 3, "xyz" - """ - ) - modcol = pytester.getmodulecol( - """ - import pytest - @pytest.fixture - def arg1(request): - return 42 - class MyClass(object): - pass - """ - ) - # this hook finds funcarg factories - rep = runner.collect_one_node(collector=modcol) - # TODO: Don't treat as Any. - clscol: Any = rep.result[0] - clscol.obj = lambda arg1: None - clscol.funcargs = {} - pytest._fillfuncargs(clscol) - assert clscol.funcargs["arg1"] == 42 - - def test_autouse_fixture( - self, pytester: Pytester, recwarn - ) -> None: # rough jstests usage - pytester.makeconftest( - """ - import pytest - def pytest_pycollect_makeitem(collector, name, obj): - if name == "MyClass": - return MyCollector.from_parent(collector, name=name) - class MyCollector(pytest.Collector): - def reportinfo(self): - return self.path, 3, "xyz" - """ - ) - modcol = pytester.getmodulecol( - """ - import pytest - @pytest.fixture(autouse=True) - def hello(): - pass - @pytest.fixture - def arg1(request): - return 42 - class MyClass(object): - pass - """ - ) - # this hook finds funcarg factories - rep = runner.collect_one_node(modcol) - # TODO: Don't treat as Any. - clscol: Any = rep.result[0] - clscol.obj = lambda: None - clscol.funcargs = {} - pytest._fillfuncargs(clscol) - assert not clscol.funcargs - - def test_wrapped_getfslineno() -> None: def func(): pass