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
相关推荐
19226386 小时前
基于LabVIEW的转子故障诊断系统:振动信号里的秘密探寻
servlet
精神病不行计算机不上班8 小时前
[Java Web]在IDEA中完整实现Servlet的示例
java·servlet·tomcat·html·intellij-idea·web
精神病不行计算机不上班11 小时前
[Java Web]Java Servlet基础
java·前端·servlet·html·mvc·web·session
好学且牛逼的马13 小时前
HttpServlet 深度拆解:从设计模式看透其核心原理
java·servlet·设计模式
兴趣使然黄小黄1 天前
【Pytest】Pytest框架快速入门
python·pytest
BD_Marathon2 天前
【JavaWeb】请求转发
servlet
m0_632482502 天前
Jenkins + Pytest +allure接口自动化测试配置与操作
jenkins·集成测试·pytest·jenkins配置
李星星BruceL2 天前
Pytest第三章(参考指南1)
python·自动化·pytest
哎呀呦呵2 天前
pytest基本使用
python·pytest
Kristen_YXQDN2 天前
PyCharm 中 pytest 运行 python 测试文件报错:D:\Python_file\.venv\Scripts\python.exe: No module named pytest
运维·开发语言·python·pycharm·pytest