首页 > 其他 > 详细

pytest---mark

时间:2020-08-19 22:04:00      阅读:73      评论:0      收藏:0      [点我收藏+]

完整的参数

  API Reference

  使用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,后续

pytest---mark

原文:https://www.cnblogs.com/myy-py/p/13530916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!