Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions python/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,27 @@ will run tests:
Note that the method being decorated must be within a subclass of ``unittest.TestCase``, since it relies on the existence of the ``subTest`` method for identifying the individual iterations.
This use of ``subTest`` also means that all iterations will be executed, not stopping at the first failure.

``classParameters`` and ``methodParameters`` require listing all combinations of the parameters.
If you want to instead iterate over all possible combinations of the parameters,
use ``classParametersProduct`` and ``methodParametersProduct``.
For example:

.. code-block:: python

class MyTestCase(unittest.TestCase):
@methodParametersProduct(foo=[1, 2], bar=["black", "white"])
def testSomething(self, foo, bar):
...

will run tests:

.. code-block:: python

testSomething(foo=1, bar="black")
testSomething(foo=1, bar="white")
testSomething(foo=2, bar="black")
testSomething(foo=2, bar="white")

See also ``pytest.mark.parametrize``, which is more complex but offers similar functionality;
however, this module is not yet approved for use.

Expand Down