diff --git a/changelog/TBD.deprecation.rst b/changelog/TBD.deprecation.rst new file mode 100644 index 00000000000..ed9779e1f50 --- /dev/null +++ b/changelog/TBD.deprecation.rst @@ -0,0 +1,6 @@ +The ``pytest._fillfuncargs`` function is now deprecated. This function was kept +for backward compatibility with an older plugin. + +It's functionality is not meant to be used directly, but if you must replace +it, use `function._request._fillfixtures()` instead, though note this is not +a public API and may break in the future. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 13d59bce2b7..4d8177a543d 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -20,6 +20,19 @@ Below is a complete list of all pytest features which are considered deprecated. :ref:`standard warning filters `. +The ``pytest._fillfuncargs`` function +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 5.5 + +This function was kept for backward compatibility with an older plugin. + +It's functionality is not meant to be used directly, but if you must replace +it, use `function._request._fillfixtures()` instead, though note this is not +a public API and may break in the future. + + + ``--no-print-logs`` command-line option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index 926cfcf19dc..2295bfe1d28 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -25,6 +25,11 @@ "since pytest 2.3 - use the newer attribute instead." ) +FILLFUNCARGS = PytestDeprecationWarning( + "The `_fillfuncargs` function is deprecated, use " + "function._request._fillfixtures() instead if you must." +) + RESULT_LOG = PytestDeprecationWarning( "--result-log is deprecated, please try the new pytest-reportlog plugin.\n" "See https://docs.pytest.org/en/latest/deprecations.html#result-log-result-log for more information." diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 0200b803c75..1813020f650 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -28,6 +28,7 @@ from _pytest.compat import NOTSET from _pytest.compat import safe_getattr from _pytest.compat import TYPE_CHECKING +from _pytest.deprecated import FILLFUNCARGS from _pytest.deprecated import FIXTURE_POSITIONAL_ARGUMENTS from _pytest.deprecated import FUNCARGNAMES from _pytest.mark import ParameterSet @@ -276,6 +277,7 @@ def reorder_items_atscope(items, argkeys_cache, items_by_argkey, scopenum): def fillfixtures(function): """ fill missing funcargs for a test function. """ + warnings.warn(FILLFUNCARGS, stacklevel=2) function._request._fillfixtures() diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index cf7dee854aa..caa44854f5f 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -1,4 +1,5 @@ import inspect +from unittest import mock import pytest from _pytest import deprecated @@ -146,3 +147,11 @@ def test_foo(): ) 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())