gpt4 book ai didi

python - Teamcity pytest 插件和单元测试报告

转载 作者:太空狗 更新时间:2023-10-30 01:16:17 25 4
gpt4 key购买 nike

我们最近放弃了自定义测试运行器/发现工具,转而使用 py.test。在 teamcity 下运行时,为了正确的单元测试报告,存在一个 pytest 插件:https://github.com/JetBrains/teamcity-python

安装时:

python setup.py install

pytest 正确发现了该插件。但是,我们不想在我们的构建机器上安装 pytest 和这个插件。相反,我们宁愿将它们打包为我们项目“工具”目录的一部分。

如何安装/配置 py.test 以“发现”此插件。我们已尝试将 pytest_plugins = "teamcity" 添加到 pytest 的 setup.cfg 文件中,但没有成功。

最佳答案

没有“pytest_plugins”配置变量(请参阅“py.test -h”末尾的输出)。但是,环境变量“PYTEST_PLUGINS”包含逗号分隔的 python 导入路径。因此,如果您的插件位于“teamcity”中/util/myplugin.py"你可以这样设置它:

export PYTEST_PLUGINS=teamcity.util.myplugin

您还可以使用命令行选项“-p teamcity.util.myplugin”来实现类似的效果。然后将其添加到您的 setup.cfg 部分:

[pytest]
addopts = -p teamcity.util.myplugin

关于python - Teamcity pytest 插件和单元测试报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14784765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com