gpt4 book ai didi

python - Pytest junit-xml 报告没有 "file"字段

转载 作者:行者123 更新时间:2023-12-05 09:07:27 27 4
gpt4 key购买 nike

我希望我的 junit-xml 看起来像这样:

<testcase classname="tests.contract.test_dummy_event.TestDummyClass" file="tests/contract/test_dummy_event.py" line="40" name="test_dummy_event" time="0.046"/>

但是,我的 junit-xml 报告如下所示:

<testcase classname="tests.contract.test_dummy_event.TestDummyClass" name="test_dummy_event" time="0.046"/>

如您所见,缺少"file"和“行”字段。知道我做错了什么吗?

配置详情:

Python: '3.6.8'
Platform: 'Linux-4.15.0-1077-aws-x86_64-with-Ubuntu-16.04-xenial'
Packages: {'pytest': '6.1.1', 'py': '1.9.0', 'pluggy': '0.13.1'}
Plugins: {'mock': '3.3.1', 'cov': '2.10.1', 'timeout': '1.4.2', 'html': '2.1.1', 'metadata': '1.10.0', 'django': '3.9.0'}

这是我运行生成 junit xml 的命令:

pytest test_dummy_event.py --junit-xml=junit_report.xml

最佳答案

显然,这与 pytest.ini 中的 junit_family 设置有关。

pytest >= 6.1.0 开始,junit_family=xunit2 的默认值,但是我正在寻找的格式显然是 junit_family=xunit1.

junit_family=xunit1 添加到 pytest.ini 后,它生成了我希望得到的报告。

PS:似乎使用 circleci tests split --split-by=timings 的 CicleCI 测试并行化需要 junit_family=xunit1 才能工作。

关于python - Pytest junit-xml 报告没有 "file"字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64796476/

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