File tree 3 files changed +10
-11
lines changed 3 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 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.
1
+ Warns for test functions that return non-None.
Original file line number Diff line number Diff line change @@ -197,9 +197,8 @@ def pytest_pyfunc_call(pyfuncitem: "Function") -> Optional[object]:
197
197
elif result is not None :
198
198
warnings .warn (
199
199
PytestReturnNotNoneWarning (
200
- "Test function returning {result}, do you mean to use `assert` instead or `return`?" .format (
201
- result = result
202
- )
200
+ f"Expected None, but the test returned { result !r} , which will be an error in a "
201
+ "future version of Pytest. Did you mean to use `assert` instead of `return`?"
203
202
)
204
203
)
205
204
return True
Original file line number Diff line number Diff line change @@ -42,13 +42,6 @@ class PytestCollectionWarning(PytestWarning):
42
42
__module__ = "pytest"
43
43
44
44
45
- @final
46
- class PytestReturnNotNoneWarning (PytestWarning ):
47
- """Warning emitted when a test function is returning value other than None."""
48
-
49
- __module__ = "pytest"
50
-
51
-
52
45
class PytestDeprecationWarning (PytestWarning , DeprecationWarning ):
53
46
"""Warning class for features that will be removed in a future version."""
54
47
@@ -62,6 +55,13 @@ class PytestRemovedIn8Warning(PytestDeprecationWarning):
62
55
__module__ = "pytest"
63
56
64
57
58
+ @final
59
+ class PytestReturnNotNoneWarning (PytestDeprecationWarning ):
60
+ """Warning emitted when a test function is returning value other than None."""
61
+
62
+ __module__ = "pytest"
63
+
64
+
65
65
@final
66
66
class PytestExperimentalApiWarning (PytestWarning , FutureWarning ):
67
67
"""Warning category used to denote experiments in pytest.
You can’t perform that action at this time.
0 commit comments