Pytest junit-xml 报告没有“文件”字段

rrl*_*ane 3 python xml pytest

我期望我的 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"/>
Run Code Online (Sandbox Code Playgroud)

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

<testcase classname="tests.contract.test_dummy_event.TestDummyClass" name="test_dummy_event" time="0.046"/>
Run Code Online (Sandbox Code Playgroud)

如您所见,缺少“文件”和“行”字段。有什么想法我做错了吗?

配置详情:

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'}
Run Code Online (Sandbox Code Playgroud)

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

pytest test_dummy_event.py --junit-xml=junit_report.xml
Run Code Online (Sandbox Code Playgroud)

rrl*_*ane 10

显然,事实证明这junit_familypytest.ini.

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

一旦我添加了junit_family=xunit1to pytest.ini,它就生成了我想要的报告。

PS:看起来 CicleCI 测试并行化circleci tests split --split-by=timings需要junit_family=xunit1工作。