import pytest
@pytest.mark.parametrize("x", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
@pytest.mark.parametrize("y", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
def test_foo(x, y):
pass
如何设置“ x”和“ y”的范围,例如x [0-16]和y [0-10]
答案 0 :(得分:1)
您正在寻找内置的range
。下面的示例:
import pytest
@pytest.mark.parametrize("x", range(17))
@pytest.mark.parametrize("y", range(11))
def test_foo(x, y):
pass
然后,根据您指定的范围(不包括该数字)更改上面的数字(即range(17)
为0-16)