Skip to content

Commit ed6701c

Browse files
Update parametrize.rst
Add warning about using generators as the value argument
1 parent b8e93b9 commit ed6701c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/en/how-to/parametrize.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ To get all combinations of multiple parametrized arguments you can stack
194194
This will run the test with the arguments set to ``x=0/y=2``, ``x=1/y=2``,
195195
``x=0/y=3``, and ``x=1/y=3`` exhausting parameters in the order of the decorators.
196196

197+
.. warning::
198+
199+
Do not use a generator as the value argument for
200+
:ref:`pytest.mark.parametrize ref` when decorating a class or module:
201+
the first test will consume the values of the generator and
202+
subsequent tests will be skipped because the generator is empty.
203+
204+
Use a list or other iterable instead of a generator.
205+
197206
.. _`pytest_generate_tests`:
198207

199208
Basic ``pytest_generate_tests`` example

0 commit comments

Comments
 (0)