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
相关推荐
diudiu96283 小时前
Maven配置阿里云镜像
java·spring·阿里云·servlet·eclipse·tomcat·maven
凌冰_11 小时前
IDEA2025 Tomcat10运行Servlet下输出出现乱码
servlet
eight *11 小时前
Jenkins自动化前后端构建全流程
servlet
小张快跑。1 天前
【Java企业级开发】(十一)企业级Web应用程序Servlet框架的使用(上)
java·前端·servlet
我一定会有钱1 天前
pytest基础
python·测试工具·测试用例·pytest
西游音月1 天前
(6)pytest+Selenium自动化测试-测试用例编写
selenium·测试用例·pytest
19226382 天前
基于LabVIEW的转子故障诊断系统:振动信号里的秘密探寻
servlet
精神病不行计算机不上班2 天前
[Java Web]在IDEA中完整实现Servlet的示例
java·servlet·tomcat·html·intellij-idea·web
精神病不行计算机不上班2 天前
[Java Web]Java Servlet基础
java·前端·servlet·html·mvc·web·session
好学且牛逼的马2 天前
HttpServlet 深度拆解:从设计模式看透其核心原理
java·servlet·设计模式