Skip to content

Commit

Permalink
pytest-dev#9886-deprecate-nose-support
Browse files Browse the repository at this point in the history
  • Loading branch information
symonk committed May 1, 2022
1 parent 2ba8fd5 commit b5c7a6d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/9886.deprecation.rst
@@ -0,0 +1 @@
The functionality for running tests written for `nose` has been officially deprecated.
14 changes: 13 additions & 1 deletion doc/en/deprecations.rst
Expand Up @@ -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
Expand All @@ -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``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion doc/en/how-to/nose.rst
Expand Up @@ -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:

Expand Down
4 changes: 4 additions & 0 deletions src/_pytest/deprecated.py
Expand Up @@ -22,6 +22,10 @@
"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".
Expand Down
4 changes: 4 additions & 0 deletions src/_pytest/nose.py
@@ -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
Expand Down Expand Up @@ -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
22 changes: 22 additions & 0 deletions testing/test_nose.py
Expand Up @@ -496,3 +496,25 @@ def test_it():
)
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)

0 comments on commit b5c7a6d

Please sign in to comment.