Remove deprecated `_fillfuncargs` function
This commit is contained in:
parent
4d7a962ca0
commit
0b0e2d2dbb
|
@ -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
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -15,7 +15,6 @@ COLLECT_FAKEMODULE_ATTRIBUTES = [
|
|||
"Item",
|
||||
"Class",
|
||||
"File",
|
||||
"_fillfuncargs",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -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="""
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue