Change junit_family default to xunit2
This commit is contained in:
parent
73e06373dc
commit
6ecbd008c4
|
@ -6,3 +6,5 @@ removed:
|
||||||
* ``@pytest.fixture`` no longer supports positional arguments, pass all arguments by keyword instead.
|
* ``@pytest.fixture`` no longer supports positional arguments, pass all arguments by keyword instead.
|
||||||
|
|
||||||
* Direct construction of ``Node`` subclasses now raise an error, use ``from_parent`` instead.
|
* Direct construction of ``Node`` subclasses now raise an error, use ``from_parent`` instead.
|
||||||
|
|
||||||
|
* The default value for ``junit_family`` has changed to ``xunit2``. If you require the old format, add ``junit_family=xunit1`` to your configuration file.
|
||||||
|
|
|
@ -57,45 +57,6 @@ A ``--show-capture`` command-line option was added in ``pytest 3.5.0`` which all
|
||||||
display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default).
|
display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default).
|
||||||
|
|
||||||
|
|
||||||
``junit_family`` default value change to "xunit2"
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
.. deprecated:: 5.2
|
|
||||||
|
|
||||||
The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, which
|
|
||||||
is an update of the old ``xunit1`` format and is supported by default in modern tools
|
|
||||||
that manipulate this type of file (for example, Jenkins, Azure Pipelines, etc.).
|
|
||||||
|
|
||||||
Users are recommended to try the new ``xunit2`` format and see if their tooling that consumes the JUnit
|
|
||||||
XML file supports it.
|
|
||||||
|
|
||||||
To use the new format, update your ``pytest.ini``:
|
|
||||||
|
|
||||||
.. code-block:: ini
|
|
||||||
|
|
||||||
[pytest]
|
|
||||||
junit_family=xunit2
|
|
||||||
|
|
||||||
If you discover that your tooling does not support the new format, and want to keep using the
|
|
||||||
legacy version, set the option to ``legacy`` instead:
|
|
||||||
|
|
||||||
.. code-block:: ini
|
|
||||||
|
|
||||||
[pytest]
|
|
||||||
junit_family=legacy
|
|
||||||
|
|
||||||
By using ``legacy`` you will keep using the legacy/xunit1 format when upgrading to
|
|
||||||
pytest 6.0, where the default format will be ``xunit2``.
|
|
||||||
|
|
||||||
In order to let users know about 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``.
|
|
||||||
|
|
||||||
Services known to support the ``xunit2`` format:
|
|
||||||
|
|
||||||
* `Jenkins <https://www.jenkins.io/>`__ with the `JUnit <https://plugins.jenkins.io/junit>`__ plugin.
|
|
||||||
* `Azure Pipelines <https://azure.microsoft.com/en-us/services/devops/pipelines>`__.
|
|
||||||
|
|
||||||
|
|
||||||
Result log (``--result-log``)
|
Result log (``--result-log``)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -132,10 +93,49 @@ Removed Features
|
||||||
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
|
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
|
||||||
an appropriate period of deprecation has passed.
|
an appropriate period of deprecation has passed.
|
||||||
|
|
||||||
|
``junit_family`` default value change to "xunit2"
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. versionchanged:: 6.0
|
||||||
|
|
||||||
|
The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, which
|
||||||
|
is an update of the old ``xunit1`` format and is supported by default in modern tools
|
||||||
|
that manipulate this type of file (for example, Jenkins, Azure Pipelines, etc.).
|
||||||
|
|
||||||
|
Users are recommended to try the new ``xunit2`` format and see if their tooling that consumes the JUnit
|
||||||
|
XML file supports it.
|
||||||
|
|
||||||
|
To use the new format, update your ``pytest.ini``:
|
||||||
|
|
||||||
|
.. code-block:: ini
|
||||||
|
|
||||||
|
[pytest]
|
||||||
|
junit_family=xunit2
|
||||||
|
|
||||||
|
If you discover that your tooling does not support the new format, and want to keep using the
|
||||||
|
legacy version, set the option to ``legacy`` instead:
|
||||||
|
|
||||||
|
.. code-block:: ini
|
||||||
|
|
||||||
|
[pytest]
|
||||||
|
junit_family=legacy
|
||||||
|
|
||||||
|
By using ``legacy`` you will keep using the legacy/xunit1 format when upgrading to
|
||||||
|
pytest 6.0, where the default format will be ``xunit2``.
|
||||||
|
|
||||||
|
In order to let users know about 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``.
|
||||||
|
|
||||||
|
Services known to support the ``xunit2`` format:
|
||||||
|
|
||||||
|
* `Jenkins <https://www.jenkins.io/>`__ with the `JUnit <https://plugins.jenkins.io/junit>`__ plugin.
|
||||||
|
* `Azure Pipelines <https://azure.microsoft.com/en-us/services/devops/pipelines>`__.
|
||||||
|
|
||||||
Node Construction changed to ``Node.from_parent``
|
Node Construction changed to ``Node.from_parent``
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. deprecated:: 6.0
|
.. versionchanged:: 6.0
|
||||||
|
|
||||||
The construction of nodes now should use the named constructor ``from_parent``.
|
The construction of nodes now should use the named constructor ``from_parent``.
|
||||||
This limitation in api surface intends to enable better/simpler refactoring of the collection tree.
|
This limitation in api surface intends to enable better/simpler refactoring of the collection tree.
|
||||||
|
|
|
@ -30,13 +30,6 @@ RESULT_LOG = PytestDeprecationWarning(
|
||||||
"See https://docs.pytest.org/en/stable/deprecations.html#result-log-result-log for more information."
|
"See https://docs.pytest.org/en/stable/deprecations.html#result-log-result-log for more information."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
JUNIT_XML_DEFAULT_FAMILY = PytestDeprecationWarning(
|
|
||||||
"The 'junit_family' default value will change to 'xunit2' in pytest 6.0. See:\n"
|
|
||||||
" https://docs.pytest.org/en/stable/deprecations.html#junit-family-default-value-change-to-xunit2\n"
|
|
||||||
"for more information."
|
|
||||||
)
|
|
||||||
|
|
||||||
COLLECT_DIRECTORY_HOOK = PytestDeprecationWarning(
|
COLLECT_DIRECTORY_HOOK = PytestDeprecationWarning(
|
||||||
"The pytest_collect_directory hook is not working.\n"
|
"The pytest_collect_directory hook is not working.\n"
|
||||||
"Please use collect_ignore in conftests or pytest_collection_modifyitems."
|
"Please use collect_ignore in conftests or pytest_collection_modifyitems."
|
||||||
|
|
|
@ -21,7 +21,6 @@ from typing import Tuple
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest import deprecated
|
|
||||||
from _pytest import nodes
|
from _pytest import nodes
|
||||||
from _pytest import timing
|
from _pytest import timing
|
||||||
from _pytest._code.code import ExceptionRepr
|
from _pytest._code.code import ExceptionRepr
|
||||||
|
@ -33,7 +32,6 @@ from _pytest.fixtures import FixtureRequest
|
||||||
from _pytest.reports import TestReport
|
from _pytest.reports import TestReport
|
||||||
from _pytest.store import StoreKey
|
from _pytest.store import StoreKey
|
||||||
from _pytest.terminal import TerminalReporter
|
from _pytest.terminal import TerminalReporter
|
||||||
from _pytest.warnings import _issue_warning_captured
|
|
||||||
|
|
||||||
|
|
||||||
xml_key = StoreKey["LogXML"]()
|
xml_key = StoreKey["LogXML"]()
|
||||||
|
@ -413,7 +411,9 @@ def pytest_addoption(parser: Parser) -> None:
|
||||||
default="total",
|
default="total",
|
||||||
) # choices=['total', 'call'])
|
) # choices=['total', 'call'])
|
||||||
parser.addini(
|
parser.addini(
|
||||||
"junit_family", "Emit XML for schema: one of legacy|xunit1|xunit2", default=None
|
"junit_family",
|
||||||
|
"Emit XML for schema: one of legacy|xunit1|xunit2",
|
||||||
|
default="xunit2",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,9 +422,6 @@ def pytest_configure(config: Config) -> None:
|
||||||
# Prevent opening xmllog on worker nodes (xdist).
|
# Prevent opening xmllog on worker nodes (xdist).
|
||||||
if xmlpath and not hasattr(config, "workerinput"):
|
if xmlpath and not hasattr(config, "workerinput"):
|
||||||
junit_family = config.getini("junit_family")
|
junit_family = config.getini("junit_family")
|
||||||
if not junit_family:
|
|
||||||
_issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)
|
|
||||||
junit_family = "xunit1"
|
|
||||||
config._store[xml_key] = LogXML(
|
config._store[xml_key] = LogXML(
|
||||||
xmlpath,
|
xmlpath,
|
||||||
config.option.junitprefix,
|
config.option.junitprefix,
|
||||||
|
|
|
@ -75,35 +75,6 @@ def test_external_plugins_integrated(testdir, plugin):
|
||||||
testdir.parseconfig("-p", plugin)
|
testdir.parseconfig("-p", plugin)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("junit_family", [None, "legacy", "xunit2"])
|
|
||||||
def test_warn_about_imminent_junit_family_default_change(testdir, junit_family):
|
|
||||||
"""Show a warning if junit_family is not defined and --junitxml is used (#6179)"""
|
|
||||||
testdir.makepyfile(
|
|
||||||
"""
|
|
||||||
def test_foo():
|
|
||||||
pass
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
if junit_family:
|
|
||||||
testdir.makeini(
|
|
||||||
"""
|
|
||||||
[pytest]
|
|
||||||
junit_family={junit_family}
|
|
||||||
""".format(
|
|
||||||
junit_family=junit_family
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
result = testdir.runpytest("--junit-xml=foo.xml")
|
|
||||||
warning_msg = (
|
|
||||||
"*PytestDeprecationWarning: The 'junit_family' default value will change*"
|
|
||||||
)
|
|
||||||
if junit_family:
|
|
||||||
result.stdout.no_fnmatch_line(warning_msg)
|
|
||||||
else:
|
|
||||||
result.stdout.fnmatch_lines([warning_msg])
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="should be reintroduced in 6.1: #7361")
|
@pytest.mark.skip(reason="should be reintroduced in 6.1: #7361")
|
||||||
def test_fillfuncargs_is_deprecated() -> None:
|
def test_fillfuncargs_is_deprecated() -> None:
|
||||||
with pytest.warns(
|
with pytest.warns(
|
||||||
|
|
Loading…
Reference in New Issue