完整的参数
使用pytest --markers
1,usefixtures
@pytest.mark.usefixtures("cleandir", "anotherfixture") def test():
2,parametrize
直接传入参数/把参数组合/对参数进入再次标记
@pytest.mark.parametrize(‘input1, input2‘,[(1,2),(2,3),(3,4)]) def est_01(self,input1, input2): print(‘执行1‘) assert input1 + input2 == 31 @pytest.mark.parametrize(‘input1‘, [1,2]) @pytest.mark.parametrize(‘input2‘, [3,4]) def est_01(self, input1, input2): print(‘执行1‘) assert input1 + input2 == 31 @pytest.mark.parametrize(‘input2‘, [3, 4,pytest.param(5, marks=pytest.mark.skip)]) def test_01(self, input2): print(‘执行1‘) assert input2 == 31
3,skip/skipif/xfail
@pytest.mark.skip(reason="no way of currently testing this") def test_the_unknown(): ...
4,后续
原文:https://www.cnblogs.com/myy-py/p/13530916.html