09、pytest多种调用方式

官方用例

python 复制代码
# content of myivoke.py
import sys
import pytest

class MyPlugin:
    def pytest_sessionfinish(self):
        print("*** test run reporting finishing")
        
if __name__ == "__main__":
    sys.exit(pytest.main(["-qq"],plugins=[MyPlugin()]))
python 复制代码
# content of other_invoke.py
import pytest

if __name__ == "__main__":
    retcode = pytest.main()
    print(retcode)
python 复制代码
# content of test_invok_01.py

def test_invok_01():
    print("test_invok_01 was invoked")
    assert 0

解读与实操

  • 通过pytest命令行调用
  • 通过python命令行调用
  • python代码中调用

应用场景

  • 个人调试或Jenkins调用,可使用python或pytest命令行
  • 测试平台,集成pytest时,可以在Python代码中调用pytest
相关推荐
lifewange6 小时前
pytest 找不到文件?直接在 pytest.ini 配置根目录 + 路径(最简单方案)
开发语言·python·pytest
谙弆悕博士9 小时前
Python快速学习——第8章:循环语句
python·学习·servlet
刚子编程10 小时前
C# Join 进阶:GroupJoin、性能对决与自定义比较器
java·servlet·c#·join
老神在在00117 小时前
保姆级教程:Pytest + Allure 接口自动化测试从 0 到 1 完整指南(含环境搭建、用例编写、报告生成、报错排坑全流程)
pycharm·pytest·测试
清水白石00817 小时前
从手写初始化到 pytest fixture:让 Python 测试既干净、可复用,又能驾驭异步并发
开发语言·python·pytest
测试员周周18 小时前
【AI测试数据及模型质量2】换一批测试数据,模型得分差20%——AI评测翻车的根子,90%在数据质量
人工智能·python·ui·单元测试·测试用例·集成测试·pytest
bzmK1DTbd2 天前
Servlet 4.0新特性:HTTP/2与异步处理支持
网络协议·http·servlet
小碗羊肉3 天前
【JavaWeb | 第四篇】分层解耦
java·后端·servlet
Y001112364 天前
JavaWeb-end
java·servlet·web
abcnull6 天前
传统的JavaWeb项目Demo快速学习!
java·servlet·elementui·vue·javaweb