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
相关推荐
合作小小程序员小小店8 小时前
网页开发,在线%旧版本旅游管理%系统,基于eclipse,html,css,jquery,servlet,jsp,mysql数据库
java·数据库·servlet·eclipse·jdk·旅游·jsp
淼_@淼14 小时前
pytest-数据驱动
pytest
老板多放葱和香菜1 天前
1大数据平台及组件搭建https://baijiahao.baidu.com/s?id=1849543147230084630
java·大数据·servlet
我的xiaodoujiao1 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 27--二次封装方法--优化断言结果
python·学习·测试工具·pytest
百***35941 天前
从0到1部署Tomcat和添加servlet(IDEA2024最新版详细教程)
hive·servlet·tomcat
CodeZ-Hao2 天前
gitea启用状态检查结合jenkins工作流实现pr门禁
servlet·jenkins·gitea
怒放de生命20102 天前
使用jenkins最新版操作指南
运维·servlet·jenkins
学网安的肆伍3 天前
【032-安全开发篇】JavaEE应用&Servlet路由技术&JDBC&Mybatis数据库&生命周期
安全·servlet·java-ee
芒克芒克3 天前
JavaWeb 文件上传全方案解析:从传统组件到现代框架实现
java·spring boot·spring·servlet·maven
淼_@淼3 天前
pytest简介
运维·服务器·pytest