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
相关推荐
Bella_chene5 小时前
IDEA中无法使用JSP内置对象
java·servlet·intellij-idea·jsp
Zz_waiting.1 天前
Javaweb - 10.4 ServletConfig 和 ServletContext
java·开发语言·前端·servlet·servletconfig·servletcontext·域对象
Zz_waiting.2 天前
Javaweb - 10.3 Servlet 生命周期
servlet
思则变2 天前
[Pytest][Part 1]Pytest 自动化测试框架
pytest
凌辰揽月2 天前
Servlet学习
hive·学习·servlet
真实的菜3 天前
Jenkins 插件深度应用:让你的CI/CD流水线如虎添翼 [特殊字符]
servlet·ci/cd·jenkins
天天爱吃肉82183 天前
ZigBee通信技术全解析:从协议栈到底层实现,全方位解读物联网核心无线技术
python·嵌入式硬件·物联网·servlet
思则变4 天前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
Zz_waiting.4 天前
Javaweb - 10.1 Servlet
servlet·tomcat·javaweb
思则变4 天前
[Pytest][Part 3]检测python package状态
pytest