Pytest @pytest.mark.parametrize装饰器

示例:

# -*- coding: utf-8 -*-

'''
业务逻辑相同,输入参数量较大, 使用 pyetst内置装饰器@pytest.mark.parametrize('参数名',参数列表)
'''

import pytest

@pytest.mark.parametrize('x,y',[(1,2),(3,4)])
def test_sum(x,y):
    sum = x+y
    print('\n')
    print(sum)

if __name__ == '__main__':
    pytest.main(['test_scripts02.py','-s'])

 

上一篇:django 将HTML 传递到前台


下一篇:解决:PytestUnknownMarkWarning: Unknown pytest.mark.webtest - is this a typo?