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
相关推荐
我的xiaodoujiao2 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 22--数据驱动--参数化处理 Json 文件
python·学习·测试工具·pytest
胜天半月子2 天前
Python自动化测试 | 快速认识并了解pytest的基本使用
服务器·python·pytest
CS Beginner3 天前
【搭建】个人博客网站的搭建
java·前端·学习·servlet·log4j·mybatis
一只小透明啊啊啊啊6 天前
Java Web 开发的核心组件:Servlet, JSP,Filter,Listener
java·前端·servlet
北珣.6 天前
自动化框架pytest基础
自动化·pytest
芙蓉王真的好17 天前
优化 Jenkins 构建脚本:避免 pnpm lockfile 相关报错的关键配置
spring·servlet·jenkins
要站在顶端7 天前
Jenkins Pipeline 多job依赖、触发多Job、并行执行及制品下载
运维·servlet·jenkins
程序员杰哥7 天前
Pytest之收集用例规则与运行指定用例
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
学习3人组8 天前
Python + requests + pytest + allure + Jenkins 构建完整的接口自动化测试框架
python·jenkins·pytest
shao91851610 天前
Gradio全解14——使用Gradio构建MCP的服务器与客户端(4)——Python包命令:uv与uvx实战
pytest·uv·1024程序员节·npx·uvx·uv pip·ruff