• Pytest_关于常用依赖库说明


    Pytest 插件库地址

    https://pypi.org/search/?q=pytest

    pytest 常用库

    均可指定豆瓣源下载 例: pip install pytest-xdist -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

    依赖库 安装 说明 使用方法
    pytest-sugar pip install pytest-sugar 以百分比表示用例执行程度, 在控制台显示
    pytest-rerunfailures pip install pytest-rerunfailures 失败重跑功能,两种方式:
    1、命令行:--reruns n(重新运行次数)–reruns-delay m(等待运行秒数)
    2、@pytest.mark.flaky(reruns=5, reruns_delay=2)
    命令行:
    pytest -v --reruns 2 --reruns-delay 5 test_rerun.py 失败用例重试2次,每次延时5秒
    函数:
    @pytest.mark.flaky(reruns=2, reruns_delay=5)
    def test_rerun():
    assert add(1, 2) == 4
    pytest-xdist pip install pytest-xdist 分布式执行
    -n 控制cpu数量
    --dist 参数来控制顺序
    1、--dist=loadscope 按照同一个模块module下的函数和同一个测试类class下的方法来分组,确保同一个模块的测试用例在同一个进程中执行
    2、--dist=loadfile 按照同一个文件名来分组,确保同一个模块的测试用例在同一个进程中执行
    pytest -s -n auto 可以自动检测到系统的CPU核数
    pytest -s -n 2 指定两个cpu跑用例
    pytest-assume pip install pytest-assume 即使断言失败,代码也还会正常执行,比直接用assert更高效 def test():
    pytest.assume(1 + 4 == 6)
    pytest.assume(2 + 4 == 5)
    pytest-ordering pip install pytest-ordering 改变测试用例顺序 @pytest.mark.run(order=2)
    def test_foo():
    print("用例11111111111")
    assert True

    @pytest.mark.run(order=1)
    def test_bar():print("用例22222222222")
    assert True
  • 相关阅读:
    接口的设置
    总结一下《vue的使用》
    标准时间对象的转换
    类数组转换为数组
    异步函数
    vue中moudles的作用及使用方法
    es5数组的新方法
    React JSX
    React更新元素 基础
    React将某段文字插入到某个元素里
  • 原文地址:https://www.cnblogs.com/c-jw/p/15157575.html
Copyright © 2020-2023  润新知