[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
fc92f5ef3e
commit
aecdc3917b
|
@ -258,17 +258,20 @@ Returning non-None value in test functions
|
||||||
|
|
||||||
.. deprecated:: 7.0
|
.. 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:
|
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
|
.. code-block:: python
|
||||||
|
|
||||||
@pytest.mark.parametrize(['a', 'b', 'result'], [
|
@pytest.mark.parametrize(
|
||||||
[1, 2, 5],
|
["a", "b", "result"],
|
||||||
[2, 3, 8],
|
[
|
||||||
[5, 3, 18],
|
[1, 2, 5],
|
||||||
])
|
[2, 3, 8],
|
||||||
|
[5, 3, 18],
|
||||||
|
],
|
||||||
|
)
|
||||||
def test_foo(a, b, result):
|
def test_foo(a, b, result):
|
||||||
return 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
|
.. code-block:: python
|
||||||
|
|
||||||
@pytest.mark.parametrize(['a', 'b', 'result'], [
|
@pytest.mark.parametrize(
|
||||||
[1, 2, 5],
|
["a", "b", "result"],
|
||||||
[2, 3, 8],
|
[
|
||||||
[5, 3, 18],
|
[1, 2, 5],
|
||||||
])
|
[2, 3, 8],
|
||||||
|
[5, 3, 18],
|
||||||
|
],
|
||||||
|
)
|
||||||
def test_foo(a, b, result):
|
def test_foo(a, b, result):
|
||||||
assert foo(a, b) == result
|
assert foo(a, b) == result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue