From aecdc3917b8a6b6761c9297f989235a2b8ceaa79 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 14:44:44 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/en/deprecations.rst | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) 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