Merge pull request #7117 from bluetech/deprecate-fillfuncargs-v2

fixtures: deprecate pytest._fillfuncargs function
This commit is contained in:
Ran Benita
2020-04-24 22:59:06 +03:00
committed by GitHub
8 changed files with 41 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
import inspect
from unittest import mock
import pytest
from _pytest import deprecated
@@ -146,3 +147,11 @@ def test_noprintlogs_is_deprecated_ini(testdir):
)
assert_no_print_logs(testdir, ())
def test__fillfuncargs_is_deprecated() -> None:
with pytest.warns(
pytest.PytestDeprecationWarning,
match="The `_fillfuncargs` function is deprecated",
):
pytest._fillfuncargs(mock.Mock())

View File

@@ -110,7 +110,7 @@ class TestFillFixtures:
def test_funcarg_basic(self, testdir):
testdir.copy_example()
item = testdir.getitem(Path("test_funcarg_basic.py"))
fixtures.fillfixtures(item)
item._request._fillfixtures()
del item.funcargs["request"]
assert len(get_public_names(item.funcargs)) == 2
assert item.funcargs["some"] == "test_func"
@@ -664,7 +664,7 @@ class TestRequestBasic:
assert val2 == 2
val2 = req.getfixturevalue("other") # see about caching
assert val2 == 2
pytest._fillfuncargs(item)
item._request._fillfixtures()
assert item.funcargs["something"] == 1
assert len(get_public_names(item.funcargs)) == 2
assert "request" in item.funcargs
@@ -681,7 +681,7 @@ class TestRequestBasic:
"""
)
item.session._setupstate.prepare(item)
pytest._fillfuncargs(item)
item._request._fillfixtures()
# successively check finalization calls
teardownlist = item.getparent(pytest.Module).obj.teardownlist
ss = item.session._setupstate

View File

@@ -4,7 +4,7 @@ from _pytest import runner
class TestOEJSKITSpecials:
def test_funcarg_non_pycollectobj(self, testdir): # rough jstests usage
def test_funcarg_non_pycollectobj(self, testdir, recwarn): # rough jstests usage
testdir.makeconftest(
"""
import pytest
@@ -34,7 +34,7 @@ class TestOEJSKITSpecials:
pytest._fillfuncargs(clscol)
assert clscol.funcargs["arg1"] == 42
def test_autouse_fixture(self, testdir): # rough jstests usage
def test_autouse_fixture(self, testdir, recwarn): # rough jstests usage
testdir.makeconftest(
"""
import pytest