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
相关推荐
wxin_VXbishe8 小时前
springboot合肥师范学院实习实训管理系统-计算机毕业设计源码31290
java·spring boot·python·spring·servlet·django·php
欲游山河十万里11 小时前
pytest(三)——参数化@pytest.mark.parametrize
pytest
识途老码3 天前
Centos7安装Jenkins
运维·servlet·jenkins
奔跑吧邓邓子3 天前
Jenkins从入门到精通,构建高效自动化流程
servlet·自动化·jenkins
人生匆匆4 天前
bluefs _flush_range allocated: osd用空间但是显示ceph_bluefs_db_used_bytes is 100%
数据库·ceph·servlet
奶茶精Gaaa4 天前
pytest
pytest
天下蒂一厨5 天前
jenkins微服务
linux·servlet·微服务·jenkins
霍格沃兹测试开发学社测试人社区6 天前
软件测试学习笔记丨Pytest 学习指南
软件测试·笔记·测试开发·学习·pytest
cyt涛7 天前
WEB服务器——Tomcat
运维·服务器·http·servlet·tomcat·web·jsp