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
相关推荐
露天赏雪2 天前
第3篇:Sentinel熔断降级实战:大模型接口抖动时的服务兜底方案
java·开发语言·人工智能·spring boot·spring·servlet·sentinel
测试界的小码农5 天前
【让 AI 生成的测试用例变成 pytest API 自动化脚本】
人工智能·测试用例·pytest
cakeism8256 天前
2026 中国企业 DevOps 平台选型:从工具链到一体化平台的决策框架
运维·servlet·devops
瑞码空间7 天前
JSP与Servlet核心开发与CRUD实战笔记
java·笔记·servlet·jsp
追星星の人9 天前
java web项目(eclipse软件)全流程备份
java·servlet
2601_9679873712 天前
Python在自动化测试中有哪些应用?
python自动化测试·selenium·appium·pytest·性能测试
小刘在重生~13 天前
Servlet_day2 (上)|Servlet 整合 JDBC|请求转发 forward|Request 作用域
hive·hadoop·servlet
Madison-No717 天前
pytest框架
pytest
鬼手点金18 天前
单轮对话:最简单的 API 调用
java·服务器·前端·javascript·react.js·servlet·tomcat
步行cgn19 天前
Servlet 中的三个域对象
servlet