虽然可以在测试函数内循环遍历所有参数的可能性,但一旦失败就终止了,即使try结果也比较南分析,所以可以使用pytest.mark.parametrize(argnames, argvalues)
@pytest
.mark
.parametrize
('passwd',
['123456',
'abcdefdfs',
'as52345fasdf4'])
def test_passwd_length(passwd
):
assert len(passwd
) >= 8
https://learning-pytest.readthedocs.io/zh/latest/doc/test-function/parametrize.html