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
相关推荐
念越5 小时前
Allure 测试报告保姆级教程:从安装到 pytest 集成与报告生成
pytest·allure
念越14 小时前
接口自动化测试从入门到实战:接口用例设计、Requests、Pytest、YAML、JSON Schema 与 Allure 报告
python·测试工具·自动化·json·pytest
霍格沃兹测试学院-小舟畅学5 天前
AI+Swagger:一键生成500条pytest接口用例
人工智能·pytest
大猫和小黄8 天前
从 Servlet 到 SSM:Java Web 进化史
servlet·java web
需要82614 天前
JVM 内存区域与对象创建:一次 GC 从哪来
java·jvm·spring boot·spring·servlet·tomcat
把头塞进显示器14 天前
电商平台-测试报告
python·selenium·pytest
昔我往昔18 天前
pytest日志问题排查记录
python·pytest
黄昏恋慕黎明22 天前
博客论坛技术迭代
python·pytest
2601_9620782322 天前
Python接口自动化流程(pytest)
python·pytest·接口自动化·测试框架·断言
杨女士YRJ22 天前
python+pytest+01
python·pytest