pytest参数化


#单个参数A
@pytest.mark.parametrize("A", [1, 2, 3, 4, 5])
def test_A(A):
    assert A > 3

#多个参数
@pytest.mark.parametrize("F,G,H",
                         ([(1,2,3),
                           (4,5,6),
                           (7,8,9)]))
def test_F(F,G,H):
    assert F+G>H

#多个参数换个写法
@pytest.mark.parametrize("K,L,M",(
        pytest.param(1,2,3),
        pytest.param(4,5,6),
        pytest.param(7,8,9)))
def test_K(K,L,M):
    assert K+L>M

 

@pytest.mark.parametrize("I",[
    pytest.param([1,2,3]),
    pytest.param([4,5,6])])
def test_I(I):
    assert I

#定义一个id做标识
@pytest.mark.parametrize("J",[
    pytest.param([1,2,3],id="first case"),
    pytest.param([4,5,6],id="second case")])
def test_J(J):
    assert J

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM