I'm getting deprecation warning from my pipelines at circleci
.
Message.
/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.
Command
- run:
name: Tests
command: |
. env/bin/activate
mkdir test-reports
python -m pytest --junitxml=test-reports/junit.xml
How should I modify command to use xunit? Is it possible to a default tool, as it is mentioned in the message? I mean without specyfing xunit or junit.
Here's full pipeline.
In your pytest.ini file add the following line:
junit_family=legacy
If you want to keep the default behavior of the --junitxml
option. Or you can accept the new version, xunit2
but not explicitly defining the junit_family variable.
Essentially what the warning is saying is you are giving the --junitxml
option in your
run
name: Tests
section not specifying the junit_family variable. You need to start to explicitly defining it to remove the warning or accept the new default.
This thread goes into more details about where to find the .ini file for pytest.
For official statement/documentation about moving from xunit1 to xunit2 read: docs.pytest.org
Also if your project contains pytest.ini file you can set junit_family usage directly from the file like:
# pytest.ini
[pytest]
minversion = 6.0
junit_family=xunit2
junit_suite_name = Pytest Tests
addopts = -ra -q -v -s --junitxml=path/to/pytest_results/pytest.xml
Run your command in this ways.
python -m pytest -o junit_family=xunit2 --junitxml=test-reports/junit.xml
python -m pytest -o junit_family=xunit1 --junitxml=test-reports/junit.xml
or
python -m pytest -o junit_family=legacy --junitxml=test-reports/junit.xml
This here describes the change in detail:
The default value of junit_family option will change to xunit2 in pytest 6.0, given that this is the version supported by default in modern tools that manipulate this type of file.
In order to smooth the transition, pytest will issue a warning in case the --junitxml option is given in the command line but junit_family is not explicitly configured in pytest.ini:
PytestDeprecationWarning: The `junit_family` default value will change to 'xunit2' in pytest 6.0. Add `junit_family=legacy` to your
pytest.ini file to silence this warning and make your suite compatible.
In order to silence this warning, users just need to configure the junit_family option explicitly:
[pytest] junit_family=legacy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With