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
相关推荐
开源优测1 天前
什么是pytest.ini及如何在Pytest中应用以提升配置效率
pytest
摸鱼仙人~2 天前
ImportError: cannot import name ‘FixtureDef‘ from ‘pytest‘
conda·pytest·fastapi
唐古乌梁海2 天前
【pytest-jira】自动化用例结合jira初版集成思路
pytest·jira
独孤求败Ace2 天前
第42天:Web开发-JavaEE应用&Servlet技术&路由配置&生命周期&过滤器Filter&监听器Listen
前端·servlet·java-ee
Beekeeper&&P...3 天前
Spring Security,servlet filter,和白名单之间的关系
hive·spring·servlet
百香果果ccc3 天前
Servlet中HttpServletRequest和HttpServletResponse的常用API
servlet
小码哥说测试3 天前
高效执行自动化用例:分布式执行工具pytest-xdist实战!
自动化测试·软件测试·功能测试·jmeter·pytest·postman·测试工程师
予早4 天前
pytest asyncio 支持插件 pytest-asyncio
pytest
汤米尼克4 天前
板块一 Servlet编程:第九节 过滤器全解 来自【汤米尼克的JAVAEE全套教程专栏】
servlet·java-ee·filter