diff --git a/changelog/5585.breaking.rst b/changelog/5585.breaking.rst new file mode 100644 index 000000000..12b9a52dd --- /dev/null +++ b/changelog/5585.breaking.rst @@ -0,0 +1,4 @@ +As per our policy, the following features have been deprecated in the 5.X series and are now +removed: + +* The ``funcargnames`` read-only property of ``FixtureRequest``, ``Metafunc``, and ``Function`` classes. Use ``fixturenames`` attribute. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 3334b5d5f..d5c7540ed 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -127,20 +127,6 @@ Services known to support the ``xunit2`` format: * `Azure Pipelines `__. -``funcargnames`` alias for ``fixturenames`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. deprecated:: 5.0 - -The ``FixtureRequest``, ``Metafunc``, and ``Function`` classes track the names of -their associated fixtures, with the aptly-named ``fixturenames`` attribute. - -Prior to pytest 2.3, this attribute was named ``funcargnames``, and we have kept -that as an alias since. It is finally due for removal, as it is often confusing -in places where we or plugin authors must distinguish between fixture names and -names supplied by non-fixture things such as ``pytest.mark.parametrize``. - - Result log (``--result-log``) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -176,6 +162,19 @@ 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. +``funcargnames`` alias for ``fixturenames`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionremoved:: 6.0 + +The ``FixtureRequest``, ``Metafunc``, and ``Function`` classes track the names of +their associated fixtures, with the aptly-named ``fixturenames`` attribute. + +Prior to pytest 2.3, this attribute was named ``funcargnames``, and we have kept +that as an alias since. It is finally due for removal, as it is often confusing +in places where we or plugin authors must distinguish between fixture names and +names supplied by non-fixture things such as ``pytest.mark.parametrize``. + ``pytest.config`` global ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index 7481473fd..d76144d60 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -19,10 +19,6 @@ DEPRECATED_EXTERNAL_PLUGINS = { "pytest_faulthandler", } -FUNCARGNAMES = PytestDeprecationWarning( - "The `funcargnames` attribute was an alias for `fixturenames`, " - "since pytest 2.3 - use the newer attribute instead." -) FILLFUNCARGS = PytestDeprecationWarning( "The `_fillfuncargs` function is deprecated, use " diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index feb145da0..c0fdc587b 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -47,7 +47,6 @@ from _pytest.config import _PluggyPlugin from _pytest.config import Config from _pytest.config.argparsing import Parser from _pytest.deprecated import FIXTURE_POSITIONAL_ARGUMENTS -from _pytest.deprecated import FUNCARGNAMES from _pytest.mark import ParameterSet from _pytest.outcomes import fail from _pytest.outcomes import TEST_OUTCOME @@ -457,12 +456,6 @@ class FixtureRequest: result.extend(set(self._fixture_defs).difference(result)) return result - @property - def funcargnames(self) -> List[str]: - """Alias attribute for ``fixturenames`` for pre-2.3 compatibility.""" - warnings.warn(FUNCARGNAMES, stacklevel=2) - return self.fixturenames - @property def node(self): """Underlying collection node (depends on current request scope).""" diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 820b7e86c..ae5108e76 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -53,7 +53,6 @@ from _pytest.config import ExitCode from _pytest.config import hookimpl from _pytest.config.argparsing import Parser from _pytest.deprecated import FSCOLLECTOR_GETHOOKPROXY_ISINITPATH -from _pytest.deprecated import FUNCARGNAMES from _pytest.fixtures import FuncFixtureInfo from _pytest.main import Session from _pytest.mark import MARK_GEN @@ -906,12 +905,6 @@ class Metafunc: self._calls = [] # type: List[CallSpec2] self._arg2fixturedefs = fixtureinfo.name2fixturedefs - @property - def funcargnames(self) -> List[str]: - """Alias attribute for ``fixturenames`` for pre-2.3 compatibility.""" - warnings.warn(FUNCARGNAMES, stacklevel=2) - return self.fixturenames - def parametrize( self, argnames: Union[str, List[str], Tuple[str, ...]], @@ -1568,12 +1561,6 @@ class Function(PyobjMixin, nodes.Item): """(compatonly) for code expecting pytest-2.2 style request objects.""" return self - @property - def funcargnames(self) -> List[str]: - """Alias attribute for ``fixturenames`` for pre-2.3 compatibility.""" - warnings.warn(FUNCARGNAMES, stacklevel=2) - return self.fixturenames - def runtest(self) -> None: """Execute the underlying test function.""" self.ihook.pytest_pyfunc_call(pyfuncitem=self) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 8ea1a75ff..f00741772 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -815,28 +815,6 @@ class TestRequestBasic: result = testdir.runpytest() result.stdout.fnmatch_lines(["*1 passed*"]) - def test_funcargnames_compatattr(self, testdir): - testdir.makepyfile( - """ - import pytest - def pytest_generate_tests(metafunc): - with pytest.warns(pytest.PytestDeprecationWarning): - assert metafunc.funcargnames == metafunc.fixturenames - @pytest.fixture - def fn(request): - with pytest.warns(pytest.PytestDeprecationWarning): - assert request._pyfuncitem.funcargnames == \ - request._pyfuncitem.fixturenames - with pytest.warns(pytest.PytestDeprecationWarning): - return request.funcargnames, request.fixturenames - - def test_hello(fn): - assert fn[0] == fn[1] - """ - ) - reprec = testdir.inline_run() - reprec.assertoutcome(passed=1) - def test_setupdecorator_and_xunit(self, testdir): testdir.makepyfile( """