"""标签:eval,接口,mark,expected,参数,测试,自动化,test,input From: https://www.cnblogs.com/jiangkeji/p/17037875.html
参数化
test_测试用例的参数,只能传2种
1、fixture fixture 'test_input' not found
2、传参数化的变量
"""
import pytest
print("两个参数")
@pytest.mark.parametrize("test_input, expected",
[("3+5", 8),
("2+4", 6),
("6 * 9", 54)
])
def test_eval(test_input, expected):
assert eval(test_input) == expected
print("一个参数")
@pytest.mark.parametrize("test_input", ["hello", "world", "demo"])
def test_eval(test_input):
assert 1 == 1
print("三个参数")
@pytest.mark.parametrize("test_input, expected, ext", [
["3+5", 8, 'xx'],
["2+4", 6, 'yy'],
["6 * 9", 54, 'zz']
])
def test_eval(test_input, expected, ext):
print(ext)
assert eval(test_input) == expected
print("两个参数")
@pytest.mark.parametrize("test_input, expected", [
[{"user": "test", "password": "1234345"}, {"code": 0, "msg": "success"}],
[{"user": "test", "password": "1234345"}, {"code": 0, "msg": "success"}],
[{"user": "test", "password": "1234345"}, {"code": 0, "msg": "success"}],
])
def test_eval(test_input, expected):
print(test_input)
print(expected)