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.
This commit is contained in:
Thomas Grainger 2022-10-10 00:10:45 +01:00 committed by GitHub
parent 196f01965e
commit 8a40fc5315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -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.

View File

@ -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:

View File

@ -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"