【问题标题】:pytest called from python code to TravisCIpytest 从 python 代码调用到 TravisCI
【发布时间】:2019-06-02 23:30:36
【问题描述】:

我正在尝试将pytest 测试集成到搅拌机下使用的一些代码中。由于搅拌机包装python的方式,我不得不从搅拌机调用的一些python代码中调用pytest

Calling pytest from Python code

我已经成功设置了一个测试,一旦出现故障,它就会运行甚至正确断言。

E       assert (1, 0, 1) == (0, 0, 1)
E         At index 0 diff: 1 != 0
E         Use -v to get the full diff
tests/test_pytest.py:11: AssertionError

但是,此结果不会通过搅拌机渗透回 TravisCI 工具,因此测试失败,因此它将测试标记为通过。这是“通过”的运行日志

https://travis-ci.org/douglaskastle/blender-fake-addon/builds/476605512

如何将来自搅拌机代码内部的pytest 的结果一直连接到 TravisCI 运行程序?

【问题讨论】:

    标签: python python-3.x travis-ci blender


    【解决方案1】:

    所需要的只是需要将来自pytest 的失败传递升级到blender,这就像使用函数返回的值并使用sys.exit 终止一样简单。

    exit_val = pytest.main(["tests"], plugins=[SetupPlugin("fake_addon")])
    sys.exit(exit_val)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-11
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      相关资源
      最近更新 更多