import pytesttest_user_data=['linda','sai','tom']@pytest.fixture(scope='module')def login(request): user=request.param print('打开首页登陆%s'%user) return user#indirect=True是把login当作函数去执行@pytest.mark.parametrize('login',test_user_data,indirect=True)def test_cart(login): usera=login print('不同用户添加购物车%s'%usera) assert usera!=''
Process finished with exit code 0
打开首页登陆linda
PASSED [ 33%]不同用户添加购物车linda
打开首页登陆sai
PASSED [ 66%]不同用户添加购物车sai
打开首页登陆tom
PASSED [100%]不同用户添加购物车tom
来源:博客园
作者:barton123
链接:https://www.cnblogs.com/QaStudy/p/11565477.html