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
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/11388593.html