parent
495a55725b
commit
bf074b37a3
|
@ -0,0 +1,8 @@
|
||||||
|
The following accesses have been documented as deprecated for years, but are now actually emitting deprecation warnings.
|
||||||
|
|
||||||
|
* Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances. Now
|
||||||
|
users will this warning::
|
||||||
|
|
||||||
|
usage of Function.Module is deprecated, please use pytest.Module instead
|
||||||
|
|
||||||
|
Users should just ``import pytest`` and access those objects using the ``pytest`` module.
|
|
@ -175,3 +175,13 @@ Previous to version 2.4 to set a break point in code one needed to use ``pytest.
|
||||||
This is no longer needed and one can use the native ``import pdb;pdb.set_trace()`` call directly.
|
This is no longer needed and one can use the native ``import pdb;pdb.set_trace()`` call directly.
|
||||||
|
|
||||||
For more details see :ref:`breakpoints`.
|
For more details see :ref:`breakpoints`.
|
||||||
|
|
||||||
|
"compat" properties
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
.. deprecated:: 3.9
|
||||||
|
|
||||||
|
Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances have long
|
||||||
|
been documented as deprecated, but started to emit warnings from pytest ``3.9`` and onward.
|
||||||
|
|
||||||
|
Users should just ``import pytest`` and access those objects using the ``pytest`` module.
|
||||||
|
|
|
@ -11,6 +11,7 @@ import _pytest._code
|
||||||
from _pytest.compat import getfslineno
|
from _pytest.compat import getfslineno
|
||||||
|
|
||||||
from _pytest.mark.structures import NodeKeywords, MarkInfo
|
from _pytest.mark.structures import NodeKeywords, MarkInfo
|
||||||
|
from _pytest.warning_types import RemovedInPytest4Warning
|
||||||
|
|
||||||
SEP = "/"
|
SEP = "/"
|
||||||
|
|
||||||
|
@ -61,11 +62,13 @@ class _CompatProperty(object):
|
||||||
if obj is None:
|
if obj is None:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
# TODO: reenable in the features branch
|
warnings.warn(
|
||||||
# warnings.warn(
|
"usage of {owner}.{name} is deprecated, please use pytest.{name} instead".format(
|
||||||
# "usage of {owner!r}.{name} is deprecated, please use pytest.{name} instead".format(
|
name=self.name, owner=owner.__name__
|
||||||
# name=self.name, owner=type(owner).__name__),
|
),
|
||||||
# PendingDeprecationWarning, stacklevel=2)
|
RemovedInPytest4Warning,
|
||||||
|
stacklevel=2,
|
||||||
|
)
|
||||||
return getattr(__import__("pytest"), self.name)
|
return getattr(__import__("pytest"), self.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -800,7 +800,7 @@ class Generator(FunctionMixin, PyCollector):
|
||||||
"%r generated tests with non-unique name %r" % (self, name)
|
"%r generated tests with non-unique name %r" % (self, name)
|
||||||
)
|
)
|
||||||
seen[name] = True
|
seen[name] = True
|
||||||
values.append(self.Function(name, self, args=args, callobj=call))
|
values.append(Function(name, self, args=args, callobj=call))
|
||||||
self.warn(deprecated.YIELD_TESTS)
|
self.warn(deprecated.YIELD_TESTS)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,23 @@ def test_yield_tests_deprecation(testdir):
|
||||||
assert result.stdout.str().count("yield tests are deprecated") == 2
|
assert result.stdout.str().count("yield tests are deprecated") == 2
|
||||||
|
|
||||||
|
|
||||||
|
def test_compat_properties_deprecation(testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
def test_foo(request):
|
||||||
|
print(request.node.Module)
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"*test_compat_properties_deprecation.py:2:*usage of Function.Module is deprecated, "
|
||||||
|
"please use pytest.Module instead*",
|
||||||
|
"*1 passed, 1 warnings in*",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.filterwarnings("default")
|
@pytest.mark.filterwarnings("default")
|
||||||
def test_funcarg_prefix_deprecation(testdir):
|
def test_funcarg_prefix_deprecation(testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
|
|
Loading…
Reference in New Issue