#9886-deprecate-nose-support

This commit is contained in:
symonk 2022-05-01 16:21:59 +01:00
parent 2ba8fd5bc5
commit b5c7a6d26a
6 changed files with 46 additions and 2 deletions

View File

@ -0,0 +1 @@
The functionality for running tests written for `nose` has been officially deprecated.

View File

@ -15,9 +15,21 @@ should be used instead.
Deprecated Features
-------------------
Below is a complete list of all pytest features which are considered deprecated. Using those features will issue
:class:`~pytest.PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
Support for tests written for nose
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.1.3
Support for running tests written for nose is now deprecated.
.. _node-ctor-fspath-deprecation:
.. _instance-collector-deprecation:
The ``pytest.Instance`` collector
@ -37,7 +49,7 @@ However, to keep such uses working, a dummy type has been instanted in ``pytest.
and importing it emits a deprecation warning. This will be removed in pytest 8.
.. _node-ctor-fspath-deprecation:
.. _support_for_tests_written_for_nose:
``fspath`` argument for Node constructors replaced with ``pathlib.Path``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -3,7 +3,8 @@
How to run tests written for nose
=======================================
``pytest`` has basic support for running tests written for nose_.
``pytest`` has basic support for running tests written for nose_. This functionality has been
deprecated and is likely to be removed in ``pytest 8.x``.
.. _nosestyle:

View File

@ -22,6 +22,10 @@ DEPRECATED_EXTERNAL_PLUGINS = {
"pytest_faulthandler",
}
NOSE_SUPPORT = PytestRemovedIn8Warning(
"Support for nose tests is deprecated and will be removed in a future release."
)
# This can be* removed pytest 8, but it's harmless and common, so no rush to remove.
# * If you're in the future: "could have been".

View File

@ -1,5 +1,8 @@
"""Run testsuites written for nose."""
import warnings
from _pytest.config import hookimpl
from _pytest.deprecated import NOSE_SUPPORT
from _pytest.fixtures import getfixturemarker
from _pytest.nodes import Item
from _pytest.python import Function
@ -38,5 +41,6 @@ def call_optional(obj: object, name: str) -> bool:
return False
# If there are any problems allow the exception to raise rather than
# silently ignoring it.
warnings.warn(NOSE_SUPPORT, stacklevel=2)
method()
return True

View File

@ -496,3 +496,25 @@ def test_nose_setup_skipped_if_non_callable(pytester: Pytester) -> None:
)
result = pytester.runpytest(p, "-p", "nose")
assert result.ret == 0
def test_nose_setup_is_deprecated(pytester: Pytester) -> None:
pytester.makepyfile(
"""
from nose.tools import with_setup
def setup_fn_no_op():
...
def teardown_fn_no_op():
...
@with_setup(setup_fn_no_op, teardown_fn_no_op)
def test_omits_warnings():
...
"""
)
output = pytester.runpytest()
message = "*PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.*"
output.stdout.fnmatch_lines([message])
output.assert_outcomes(passed=1, warnings=2)