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
相关推荐
nvd113 小时前
深入分析:Pytest异步测试中的数据库会话事件循环问题
数据库·pytest
程序员老徐9 小时前
SpringBoot嵌入Tomcat注册Servlet、Filter流程
spring boot·servlet·tomcat
程序员雷叔10 小时前
在postman设置请求里带动态token,看看这两种方法!
selenium·测试工具·单元测试·测试用例·pytest·lua·postman
cly114 小时前
Jenkins重置管理员密码
运维·servlet·jenkins
花酒锄作田1 天前
[python]Flask - Tracking ID的设计
python·flask·pytest
测试秃头怪1 天前
Python测试框架Pytest的参数化
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
未定义.2212 天前
第7篇:跨端拓展!Playwright+Appium实现Web+移动端全覆盖
python·ui·appium·自动化·jenkins·pytest
m0_748252382 天前
Servlet 数据库访问
数据库·servlet
派大鑫wink2 天前
【Day33】Servlet 基础:生命周期、Request/Response 对象实战
java·servlet
栗子叶2 天前
Spring 中 Servlet 容器和 Python FastAPI 对比
python·spring·servlet·fastapi