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
相关推荐
lv__pf1 天前
servlet与jsp
java·开发语言·servlet
风起洛阳@不良使4 天前
Servlet体系
servlet
X1A0RAN4 天前
Jenkins Pipeline 变量打印指南
运维·servlet·jenkins
sun༒5 天前
Java Web 三大组件之 Servlet:从入门到理解生命周期
java·servlet·web
IKUN家族6 天前
Spring MVC(三)
运维·服务器·spring boot·spring·servlet·java-ee
spider_xcxc7 天前
Jenkins 遇见 Argo CD:构建可靠 GitOps 流水线的实战指南
java·开发语言·servlet
久久学姐7 天前
Python+Playwright+Pytest+BDD,用FSM打造高效测试框架
python·pytest·bdd·playwright·fsm
上海安当技术7 天前
统一身份认证平台怎么落地?11 个异构业务系统接入 ASP 的完整实施路径
数据库·servlet·架构·kubernetes·jenkins
小白上线*^_^*7 天前
Pytest 自动化测试框架速通指南(二)
软件测试·pytest·python测试框架·ai测试基础
豆角焖肉8 天前
Servlet :生命周期、配置与实战
servlet