From 8a40fc53152e9430f66f4a7eb62e30eb21d0b311 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 10 Oct 2022 00:10:45 +0100 Subject: [PATCH] PytestReturnNotNoneWarning now subclasses PytestRemovedIn8Warning (#10196) As discussed in https://github.com/pytest-dev/pytest/pull/9956#issuecomment-1132710934. Also added PytestRemovedIn8Warning to the reference docs. --- changelog/10196.trivial.rst | 1 + doc/en/reference/reference.rst | 3 +++ src/_pytest/warning_types.py | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog/10196.trivial.rst diff --git a/changelog/10196.trivial.rst b/changelog/10196.trivial.rst new file mode 100644 index 000000000..edf458f84 --- /dev/null +++ b/changelog/10196.trivial.rst @@ -0,0 +1 @@ +:class:`~pytest.PytestReturnNotNoneWarning` is now a subclass of :class:`~pytest.PytestRemovedIn8Warning`: the plan is to make returning non-``None`` from tests an error in the future. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index c4402ff41..6edb88b92 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1136,6 +1136,9 @@ Custom warnings generated in some situations such as improper usage or deprecate .. autoclass:: pytest.PytestReturnNotNoneWarning :show-inheritance: +.. autoclass:: pytest.PytestRemovedIn8Warning + :show-inheritance: + .. autoclass:: pytest.PytestUnhandledCoroutineWarning :show-inheritance: diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index 3be1648fe..620860c1b 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -51,14 +51,13 @@ class PytestDeprecationWarning(PytestWarning, DeprecationWarning): __module__ = "pytest" -@final class PytestRemovedIn8Warning(PytestDeprecationWarning): """Warning class for features that will be removed in pytest 8.""" __module__ = "pytest" -class PytestReturnNotNoneWarning(PytestDeprecationWarning): +class PytestReturnNotNoneWarning(PytestRemovedIn8Warning): """Warning emitted when a test function is returning value other than None.""" __module__ = "pytest"