PyTest 弃用:'junit_family 默认值将更改为'xunit2'

Pio*_*rus 10 python pytest circleci

我在circleci.

留言

/home/circleci/evobench/env/lib/python3.7/site-packages/_pytest/junitxml.py:436: PytestDeprecationWarning: The 'junit_family' default value will change to 'xunit2' in pytest 6.0.
Run Code Online (Sandbox Code Playgroud)

命令

- run:
    name: Tests
    command: |
      . env/bin/activate
      mkdir test-reports
      python -m pytest --junitxml=test-reports/junit.xml
Run Code Online (Sandbox Code Playgroud)

我应该如何修改命令以使用 xunit?是否可以使用默认工具,如消息中所述?我的意思是不指定 xunit 或 junit。

这是完整的管道

H6.*_*H6. 10

以这种方式运行您的命令。

与 xunit2

python -m pytest -o junit_family=xunit2 --junitxml=test-reports/junit.xml

与 xunit1

python -m pytest -o junit_family=xunit1 --junitxml=test-reports/junit.xml 或者

python -m pytest -o junit_family=legacy --junitxml=test-reports/junit.xml

这里详细描述了更改:

junit_family 选项的默认值将在 pytest 6.0 中更改为 xunit2,因为这是操作此类文件的现代工具中默认支持的版本。

为了平滑过渡,如果命令行中给出了 --junitxml 选项,但 pytest.ini 中未明确配置 junit_family ,则 pytest 将发出警告:

PytestDeprecationWarning: The `junit_family` default value will change to 'xunit2' in pytest 6.0.   Add `junit_family=legacy` to your
Run Code Online (Sandbox Code Playgroud)

pytest.ini 文件以消除此警告并使您的套件兼容。

为了消除这个警告,用户只需要显式配置 junit_family 选项:

[pytest]
junit_family=legacy
Run Code Online (Sandbox Code Playgroud)