zoukankan      html  css  js  c++  java
  • pytest扫盲19--pytest重运行机制

    安装:

      pip install pytest-rerunfailures -i https://pypi.tuna.tsinghua.edu.cn/simple

    环境要求:

      Python 3.5, 最高 3.8, or PyPy3

      pytest 5.0或更高版本

    参数:

      命令行参数:--reruns num(重运行次数),--reruns-delay time(重运行间隔时间)

      装饰器:@pytest.mark.flaky(reruns=num, reruns-delay=time)

    命令行运行:

      pytest.main()运行

    pytest.main(['-s', '-q', '--reruns=2', '--reruns-delay=2', 'test_demo_17_reruns.py'])

      cmd运行

    pytest --reruns 2 --reruns-delay 2 -s -q test_demo_17_reruns.py

      运行结果:

    E:personalpython38python.exe E:/personal/GitWorkSpace/pytest_basic/main.py
    test_demo_17_reruns.py::test_1
    当前用例运行测试环境:http://xx.xx.xx.xx:xxxx
    R当前用例运行测试环境:http://xx.xx.xx.xx:xxxx
    R当前用例运行测试环境:http://xx.xx.xx.xx:xxxx
    F

    装饰器运行:

    # File  : test_demo_17_reruns.py
    # IDE   : PyCharm
    
    import pytest
    @pytest.mark.flaky(reruns=2)
    def test_1():
        assert 3 is 2

     

    注意事项:

      1、如果指定了用例的重新运行次数,则在命令行添加--reruns对这些用例是不会生效的。

      2、不可和 pytest.fixtures() 一起使用。

  • 相关阅读:
    状态机
    折半查找函数
    宽字符与多字符相互转换
    安装交叉编译工具
    make menuconfig提示'make menuconfig' requires the ncurses libraries.
    IIC总线
    关于文字编码
    傅里叶变换
    韦东山视频_第27课_dma设备驱动程序
    linux内核宏之——-PERF_ALIGN
  • 原文地址:https://www.cnblogs.com/xiaohuboke/p/13566603.html
Copyright © 2011-2022 走看看