【发布时间】:2023-01-20 20:31:05
【问题描述】:
在许多带有参数化数据的 PyTest 脚本示例中,例如
@pytest.mark.parametrize("input1, input2, output", [(5, 5, 10), (7, 5, 12)])
def test_add(input1, input2, output):
assert input1 + input2 == output, "failed"
注解。但是,我需要在 PyTest 参数化中为多个 test_ 方法获取 cvs/xlsx 数据。
可以说我在 CSV 中有表格
| input1 | input2 | output |
|---|---|---|
| 5 | 5 | 10 |
| 7 | 5 | 12 |
谁能建议从 CSV 读取数据并将其用于上述测试方法的详细解决方案?
【问题讨论】:
标签: python-3.x pytest