Skip to content

Commit d6258f9

Browse files
committed
Deprecate funcargnames alias
1 parent 4f57d40 commit d6258f9

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/_pytest/compat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,7 @@ class FuncargnamesCompatAttr:
324324
@property
325325
def funcargnames(self):
326326
""" alias attribute for ``fixturenames`` for pre-2.3 compatibility"""
327+
from _pytest.deprecated import FUNCARGNAMES
328+
329+
warnings.warn(FUNCARGNAMES, stacklevel=2)
327330
return self.fixturenames

src/_pytest/deprecated.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"getfuncargvalue is deprecated, use getfixturevalue"
3333
)
3434

35+
FUNCARGNAMES = PytestDeprecationWarning(
36+
"The `funcargnames` attribute was an alias for `fixturenames`, "
37+
"since pytest 2.3 - use the newer attribute instead."
38+
)
39+
3540
RAISES_MESSAGE_PARAMETER = PytestDeprecationWarning(
3641
"The 'message' parameter is deprecated.\n"
3742
"(did you mean to use `match='some regex'` to check the exception message?)\n"

src/_pytest/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def _schedule_finalizers(self, fixturedef, subrequest):
660660
# if the executing fixturedef was not explicitly requested in the argument list (via
661661
# getfixturevalue inside the fixture call) then ensure this fixture def will be finished
662662
# first
663-
if fixturedef.argname not in self.funcargnames:
663+
if fixturedef.argname not in self.fixturenames:
664664
fixturedef.addfinalizer(
665665
functools.partial(self._fixturedef.finish, request=self)
666666
)

testing/python/fixtures.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,15 @@ def test_funcargnames_compatattr(self, testdir):
793793
"""
794794
import pytest
795795
def pytest_generate_tests(metafunc):
796-
assert metafunc.funcargnames == metafunc.fixturenames
796+
with pytest.warns(pytest.PytestDeprecationWarning):
797+
assert metafunc.funcargnames == metafunc.fixturenames
797798
@pytest.fixture
798799
def fn(request):
799-
assert request._pyfuncitem.funcargnames == \
800-
request._pyfuncitem.fixturenames
801-
return request.funcargnames, request.fixturenames
800+
with pytest.warns(pytest.PytestDeprecationWarning):
801+
assert request._pyfuncitem.funcargnames == \
802+
request._pyfuncitem.fixturenames
803+
with pytest.warns(pytest.PytestDeprecationWarning):
804+
return request.funcargnames, request.fixturenames
802805
803806
def test_hello(fn):
804807
assert fn[0] == fn[1]

testing/python/metafunc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ def test_parametrize_scope_overrides(self, testdir, scope, length):
12051205
import pytest
12061206
values = []
12071207
def pytest_generate_tests(metafunc):
1208-
if "arg" in metafunc.funcargnames:
1208+
if "arg" in metafunc.fixturenames:
12091209
metafunc.parametrize("arg", [1,2], indirect=True,
12101210
scope=%r)
12111211
@pytest.fixture

0 commit comments

Comments
 (0)