[英]Parameterized testing with 2 arguments in pytest
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
How I can set a range for "x" and "y", like as x[0-16] and y[0-10]如何为“x”和“y”设置范围,例如 x[0-16] 和 y[0-10]
You're looking for the range
builtin for that one.您正在寻找内置的range
。 Example below:下面的例子:
import pytest
@pytest.mark.parametrize("x", range(17))
@pytest.mark.parametrize("y", range(11))
def test_foo(x, y):
pass
You then change the numbers above based your specific range exclusive of that number (ie, 0 - 16 for range(17)
)然后根据不包括该数字的特定范围更改上面的数字(即range(17)
为 0 - 16 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.