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
相关推荐
lifewange3 小时前
pytest-类中测试方法、多文件批量执行
开发语言·python·pytest
xinzheng新政10 小时前
Javascript 深入学习基础·4
javascript·学习·servlet
身如柳絮随风扬15 小时前
Servlet:访问流程、核心接口与生命周期
java·servlet·web
:12117 小时前
请求对象响应对象2
servlet
ruan11451418 小时前
关于HashMap--个人学习记录
java·jvm·servlet
凌冰_2 天前
Servlet+Thymeleaf + Fetch 实现无刷新异步请求
java·servlet
椰猫子2 天前
Javaweb(Servlet)
servlet
我的xiaodoujiao2 天前
API 接口自动化测试详细图文教程学习系列9--Requests模块
python·学习·测试工具·pytest
如若1232 天前
ERROR:pdf2zh.converter:‘str‘ object has no attribute ‘choices‘ converter.py:357
java·开发语言·servlet
:1212 天前
servlet
servlet