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
相关推荐
凛铄linshuo1 天前
分析业务流程什么时候适合断言?
python·pytest
凛铄linshuo2 天前
自动化测试:pytest第一个实例学习
学习·pytest
鸥梨菌Honevid2 天前
UVM 中 REQ 和 RSP 类型详解:从通信模型到 item_done 与 put_response
java·前端·servlet
不老刘4 天前
Maven 多医院分支场景下 groupId 的设计与 Jenkins 落地实践
servlet·jenkins·maven
Helix2505 天前
Python单元测试实战:pytest框架从入门到企业级测试体系搭建指南
python·单元测试·实战·mock·pytest·测试覆盖率·fixture
代码什么用7 天前
Java Web 7-10
java·servlet
在世修行9 天前
干货:pytest
pytest·fixture·pytest assert
小小龙学IT11 天前
Python pytest 测试框架深度解析:从断言重写到插件生态的工程化测试体系
网络·python·pytest
落魄大学生之流水线上谋生计13 天前
pytest 入门与实践:从第一个测试到可维护的测试体系
pytest
念越14 天前
Allure 测试报告保姆级教程:从安装到 pytest 集成与报告生成
pytest·allure