Remove Request.getfuncargvalue
This commit is contained in:
parent
4f9bf028f5
commit
be91c4d932
|
@ -0,0 +1,4 @@
|
|||
As per our policy, the following features have been deprecated in the 4.X series and are now being
|
||||
removed:
|
||||
|
||||
* ``Request.getfuncargvalue``: use ``Request.getfixturevalue`` instead.
|
|
@ -36,9 +36,6 @@ FIXTURE_NAMED_REQUEST = PytestDeprecationWarning(
|
|||
|
||||
CFG_PYTEST_SECTION = "[pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead."
|
||||
|
||||
GETFUNCARGVALUE = RemovedInPytest4Warning(
|
||||
"getfuncargvalue is deprecated, use getfixturevalue"
|
||||
)
|
||||
|
||||
FUNCARGNAMES = PytestDeprecationWarning(
|
||||
"The `funcargnames` attribute was an alias for `fixturenames`, "
|
||||
|
|
|
@ -470,13 +470,6 @@ class FixtureRequest(FuncargnamesCompatAttr):
|
|||
"""
|
||||
return self._get_active_fixturedef(argname).cached_result[0]
|
||||
|
||||
def getfuncargvalue(self, argname):
|
||||
""" Deprecated, use getfixturevalue. """
|
||||
from _pytest import deprecated
|
||||
|
||||
warnings.warn(deprecated.GETFUNCARGVALUE, stacklevel=2)
|
||||
return self.getfixturevalue(argname)
|
||||
|
||||
def _get_active_fixturedef(self, argname):
|
||||
try:
|
||||
return self._fixture_defs[argname]
|
||||
|
|
|
@ -32,10 +32,6 @@ def test_pytest_custom_cfg_unsupported(testdir):
|
|||
testdir.runpytest("-c", "custom.cfg")
|
||||
|
||||
|
||||
def test_getfuncargvalue_is_deprecated(request):
|
||||
pytest.deprecated_call(request.getfuncargvalue, "tmpdir")
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings("default")
|
||||
def test_resultlog_is_deprecated(testdir):
|
||||
result = testdir.runpytest("--help")
|
||||
|
|
|
@ -599,8 +599,7 @@ class TestRequestBasic:
|
|||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(["* 2 passed in *"])
|
||||
|
||||
@pytest.mark.parametrize("getfixmethod", ("getfixturevalue", "getfuncargvalue"))
|
||||
def test_getfixturevalue(self, testdir, getfixmethod):
|
||||
def test_getfixturevalue(self, testdir):
|
||||
item = testdir.getitem(
|
||||
"""
|
||||
import pytest
|
||||
|
@ -613,35 +612,22 @@ class TestRequestBasic:
|
|||
def test_func(something): pass
|
||||
"""
|
||||
)
|
||||
import contextlib
|
||||
|
||||
if getfixmethod == "getfuncargvalue":
|
||||
warning_expectation = pytest.warns(DeprecationWarning)
|
||||
else:
|
||||
# see #1830 for a cleaner way to accomplish this
|
||||
@contextlib.contextmanager
|
||||
def expecting_no_warning():
|
||||
yield
|
||||
|
||||
warning_expectation = expecting_no_warning()
|
||||
|
||||
req = item._request
|
||||
with warning_expectation:
|
||||
fixture_fetcher = getattr(req, getfixmethod)
|
||||
with pytest.raises(FixtureLookupError):
|
||||
fixture_fetcher("notexists")
|
||||
val = fixture_fetcher("something")
|
||||
assert val == 1
|
||||
val = fixture_fetcher("something")
|
||||
assert val == 1
|
||||
val2 = fixture_fetcher("other")
|
||||
assert val2 == 2
|
||||
val2 = fixture_fetcher("other") # see about caching
|
||||
assert val2 == 2
|
||||
pytest._fillfuncargs(item)
|
||||
assert item.funcargs["something"] == 1
|
||||
assert len(get_public_names(item.funcargs)) == 2
|
||||
assert "request" in item.funcargs
|
||||
|
||||
with pytest.raises(FixtureLookupError):
|
||||
req.getfixturevalue("notexists")
|
||||
val = req.getfixturevalue("something")
|
||||
assert val == 1
|
||||
val = req.getfixturevalue("something")
|
||||
assert val == 1
|
||||
val2 = req.getfixturevalue("other")
|
||||
assert val2 == 2
|
||||
val2 = req.getfixturevalue("other") # see about caching
|
||||
assert val2 == 2
|
||||
pytest._fillfuncargs(item)
|
||||
assert item.funcargs["something"] == 1
|
||||
assert len(get_public_names(item.funcargs)) == 2
|
||||
assert "request" in item.funcargs
|
||||
|
||||
def test_request_addfinalizer(self, testdir):
|
||||
item = testdir.getitem(
|
||||
|
|
Loading…
Reference in New Issue