diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 23bcb2fba..ab76a5203 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -258,17 +258,20 @@ Returning non-None value in test functions .. deprecated:: 7.0 -A :class:`pytest.PytestReturnNotNoneWarning` is now emitted if a test function returns something other than `None`. +A :class:`pytest.PytestReturnNotNoneWarning` is now emitted if a test function returns something other than `None`. This prevents a common mistake among beginners that expect that returning a `bool` would cause a test to pass or fail, for example: .. code-block:: python - @pytest.mark.parametrize(['a', 'b', 'result'], [ - [1, 2, 5], - [2, 3, 8], - [5, 3, 18], - ]) + @pytest.mark.parametrize( + ["a", "b", "result"], + [ + [1, 2, 5], + [2, 3, 8], + [5, 3, 18], + ], + ) def test_foo(a, b, result): return foo(a, b) == result @@ -278,11 +281,14 @@ The proper fix is to change the `return` to an `assert`: .. code-block:: python - @pytest.mark.parametrize(['a', 'b', 'result'], [ - [1, 2, 5], - [2, 3, 8], - [5, 3, 18], - ]) + @pytest.mark.parametrize( + ["a", "b", "result"], + [ + [1, 2, 5], + [2, 3, 8], + [5, 3, 18], + ], + ) def test_foo(a, b, result): assert foo(a, b) == result