update changelog, warning msg and warning inherit
This commit is contained in:
parent
238a5cae9c
commit
7855fdefd2
|
@ -1 +1 @@
|
||||||
Warns for test functions that return non-None. Now in `pytest_pyfunc_call` after the `async_warn_and_skip` it will check for if the return is something other than None.
|
Warns for test functions that return non-None.
|
||||||
|
|
|
@ -197,9 +197,8 @@ def pytest_pyfunc_call(pyfuncitem: "Function") -> Optional[object]:
|
||||||
elif result is not None:
|
elif result is not None:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
PytestReturnNotNoneWarning(
|
PytestReturnNotNoneWarning(
|
||||||
"Test function returning {result}, do you mean to use `assert` instead or `return`?".format(
|
f"Expected None, but the test returned {result!r}, which will be an error in a "
|
||||||
result=result
|
"future version of Pytest. Did you mean to use `assert` instead of `return`?"
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -42,13 +42,6 @@ class PytestCollectionWarning(PytestWarning):
|
||||||
__module__ = "pytest"
|
__module__ = "pytest"
|
||||||
|
|
||||||
|
|
||||||
@final
|
|
||||||
class PytestReturnNotNoneWarning(PytestWarning):
|
|
||||||
"""Warning emitted when a test function is returning value other than None."""
|
|
||||||
|
|
||||||
__module__ = "pytest"
|
|
||||||
|
|
||||||
|
|
||||||
class PytestDeprecationWarning(PytestWarning, DeprecationWarning):
|
class PytestDeprecationWarning(PytestWarning, DeprecationWarning):
|
||||||
"""Warning class for features that will be removed in a future version."""
|
"""Warning class for features that will be removed in a future version."""
|
||||||
|
|
||||||
|
@ -62,6 +55,13 @@ class PytestRemovedIn8Warning(PytestDeprecationWarning):
|
||||||
__module__ = "pytest"
|
__module__ = "pytest"
|
||||||
|
|
||||||
|
|
||||||
|
@final
|
||||||
|
class PytestReturnNotNoneWarning(PytestDeprecationWarning):
|
||||||
|
"""Warning emitted when a test function is returning value other than None."""
|
||||||
|
|
||||||
|
__module__ = "pytest"
|
||||||
|
|
||||||
|
|
||||||
@final
|
@final
|
||||||
class PytestExperimentalApiWarning(PytestWarning, FutureWarning):
|
class PytestExperimentalApiWarning(PytestWarning, FutureWarning):
|
||||||
"""Warning category used to denote experiments in pytest.
|
"""Warning category used to denote experiments in pytest.
|
||||||
|
|
Loading…
Reference in New Issue