parameterized icon indicating copy to clipboard operation
parameterized copied to clipboard

Is it possible to stack decorators to create a matrix similar to pytest.mark.parameterize?

Open markddavidoff opened this issue 4 years ago • 3 comments

Ex:

@parameterized.expand([(True,), (False,)])
@parameterized.expand([(0,), (1,)])
def test_test(_bool, _num):
    """
    would get:
    True 0
    False 0
    True 1
    False 1
    """

markddavidoff avatar Mar 26 '21 19:03 markddavidoff

Similar to #102

markddavidoff avatar Mar 26 '21 19:03 markddavidoff

This feature would be nice, but in the meantime I am using itertools.product(), so your example above would look something like:

import itertools
...

@parameterized.expand(itertools.product([True, False], [0, 1], repeat=1))
def test_test(_bool, _num):
    ...

RevolutionTech avatar May 14 '21 22:05 RevolutionTech

Alternative syntax you can use for this without itertools.product() is:

@parameterized.expand(
    (_bool, _num)
    for _bool in (True, False)
    for _num in (0, 1)
)
def test_test(_bool, _num):
    ...

stucox avatar Jan 09 '22 21:01 stucox