繁体   English   中英

pytest 中带有 2 个参数的参数化测试

[英]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

如何为“x”和“y”设置范围,例如 x[0-16] 和 y[0-10]

您正在寻找内置的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 )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM