Skip to content

Commit

Permalink
Update parametrize.rst
Browse files Browse the repository at this point in the history
Add an example for enforcing explicit argument declaration
References pytest-dev#5712
  • Loading branch information
erheron committed Dec 10, 2019
1 parent 23a0582 commit cf28f67
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/en/example/parametrize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,31 @@ The result of this test will be successful:
========================== no tests ran in 0.12s ===========================
Note, that each argument in `parametrize` list should be explicitly declared in
python test function or via `indirect`. E.g. the following test will not run:

.. code-block:: python
# content of test_explicit_argnames.py
import pytest
@pytest.fixture
def fixture(argument):
return argument
@pytest.mark.parametrize("argument", ["foobar"])
def test_explicit(fixture):
assert "foobar" == fixture
# should be either test_explicit(fixture, argument) or
#
#@pytest.mark.parametrize("argument", ['foobar'], indirect=['argument'])
#def test_explicit(fixture)
#or
#@pytest.mark.parametrize("argument", ['foobar'], indirect=True)
#def test_explicit(fixture)
.. regendoc:wipe
Parametrizing test methods through per-class configuration
Expand Down

0 comments on commit cf28f67

Please sign in to comment.