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
相关推荐
2601_967980111 天前
python pytest怎样测试代码
python·pytest·测试·文档·断言
2601_967980112 天前
python pytest如何编写测试
python·测试用例·pytest·函数·assert
2601_967980112 天前
Python pytest如何实现参数化测试
测试用例·pytest·python测试框架·参数化测试·ids参数
露天赏雪16 天前
第3篇:Sentinel熔断降级实战:大模型接口抖动时的服务兜底方案
java·开发语言·人工智能·spring boot·spring·servlet·sentinel
测试界的小码农19 天前
【让 AI 生成的测试用例变成 pytest API 自动化脚本】
人工智能·测试用例·pytest
cakeism82520 天前
2026 中国企业 DevOps 平台选型:从工具链到一体化平台的决策框架
运维·servlet·devops
瑞码空间21 天前
JSP与Servlet核心开发与CRUD实战笔记
java·笔记·servlet·jsp
追星星の人23 天前
java web项目(eclipse软件)全流程备份
java·servlet
2601_967987371 个月前
Python在自动化测试中有哪些应用?
python自动化测试·selenium·appium·pytest·性能测试
小刘在重生~1 个月前
Servlet_day2 (上)|Servlet 整合 JDBC|请求转发 forward|Request 作用域
hive·hadoop·servlet