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 小时前
[python]Flask - Tracking ID的设计
python·flask·pytest
测试秃头怪6 小时前
Python测试框架Pytest的参数化
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
未定义.22112 小时前
第7篇:跨端拓展!Playwright+Appium实现Web+移动端全覆盖
python·ui·appium·自动化·jenkins·pytest
m0_7482523813 小时前
Servlet 数据库访问
数据库·servlet
派大鑫wink13 小时前
【Day33】Servlet 基础:生命周期、Request/Response 对象实战
java·servlet
栗子叶1 天前
Spring 中 Servlet 容器和 Python FastAPI 对比
python·spring·servlet·fastapi
未定义.2211 天前
第5篇:进阶优化:数据驱动+日志体系+失败重试实战
python·ui·自动化·jenkins·集成测试·pytest
未定义.2212 天前
第4篇:企业级框架搭建,Pytest+PO模式从0到1实战
python·ui·自动化·jenkins·集成测试·pytest
文人sec2 天前
pytest2-Allure自动化测试报告
python·功能测试·自动化·pytest
亲爱的非洲野猪2 天前
SpringBoot启动流程深度剖析:从@SpringBootApplication到Servlet容器就绪
hive·spring boot·servlet