kaste / PyTest

pytest runner and view annotator for sublime text
21 stars 6 forks source link

Deprecation warning #25

Closed MPvHarmelen closed 4 years ago

MPvHarmelen commented 4 years ago

The following warning

(virtual environment)/lib/python3.6/site-packages/_pytest/junitxml.py:436
(virtual environment)/lib/python3.6/site-packages/_pytest/junitxml.py:436: 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.
    _issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
- generated xml file: ~/.config/sublime-text-3/Cache/PyTest/last-run.xml -

Is caused by the following line: https://github.com/kaste/PyTest/blob/04cf2aabcf006f6a3b44aeb1d0d0d4d76165bb1d/pytest_exec.py#L43

The way to solve this, according to pytest:

junit_family default value change to "xunit2"

Deprecated since version 5.2.

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
kaste commented 4 years ago

I noticed that as well, yesterday or so πŸ˜€, but I did not find a way to pass junit_family or junit-family via command line. I think we're compat with the new/next default xunit2 as well. πŸ™„

Any idea?

YoSTEALTH commented 4 years ago

Creating a pytest.ini file inside test folder and adding: [pytest] junit_family = xunit2

Makes the warning go away! not sure if this is the best solution.

kaste commented 4 years ago

But every user for every project would have to add this, I cannot control this.

YoSTEALTH commented 4 years ago

Actually you can set options to -o junit_family=xunit2this way no need to create .ini file. Maybe you can set this as default?

kaste commented 4 years ago

That sounds promising, will try.