pytest-接口传参参数化
1、一个参数传值
@pytest.mark.parametrize("a", [3,6,9])
def test_a(self,a):
print("test data:a=%d"%a)
assert a%3 ==0
2、多个参数传值
@pytest.mark.parametrize("a,b",[(1,2),(2,1)])
def test_b(self,a,b):
print("test data:a=%d,b=%d"%(a,b))
assert a + b ==3
3、函数返回传值
def return_test_data():
return [(1,2),(2,1)]
@pytest.mark.parametrize("a,b",return_test_data() )
def test_c(self,a,b):
print("test data:a=%d,b=%d" % (a, b))
assert a + b == 3