6-データ駆動型-パラメータ化

データドリブン-パラメトリック

@ pytest.mark.parametrize( '変数'、パラメータリスト)
@ pytest.mark.parametrize( '複数の変数'、子要素はタプルのパラメータリストです)

import pytest

class TestLogin:
    @pytest.mark.parametrize('a', [1,2])
    def test_login01(self,a):
        assert 1 + 1 == a

    @pytest.mark.parametrize('a,b', [(1, 2), (3, 4)])
    def test_login02(self,a,b):
        assert 2 + a == b

if __name__ == '__main__':
    pytest.main(['test_func01.py']) 

結果:
ここに画像の説明を挿入

おすすめ

転載: blog.csdn.net/weixin_45128456/article/details/112999267