diff --git a/AUTHORS b/AUTHORS index 7f742fb4083..1dfa55b131f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -275,6 +275,7 @@ Manuel Krebber Marc Mueller Marc Schlaich Marcelo Duarte Trevisani +Marcin Augustynów Marcin Bachry Marc Bresson Marco Gorelli diff --git a/changelog/12736.improvement.rst b/changelog/12736.improvement.rst new file mode 100644 index 00000000000..5fdb14e2ef5 --- /dev/null +++ b/changelog/12736.improvement.rst @@ -0,0 +1,3 @@ +Added a new attribute `name` with the fixed value `"pytest tests"` to the root tag `testsuites` of the junit-xml generated by pytest. + +This attribute is part of many junit-xml specifications and is even part of the `junit-10.xsd` specification that pytest's implementation is based on. diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index ec9922ee7bd..dc35e3aac15 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -670,6 +670,7 @@ def pytest_sessionfinish(self) -> None: for node_reporter in self.node_reporters_ordered: suite_node.append(node_reporter.to_xml()) testsuites = ET.Element("testsuites") + testsuites.set("name", "pytest tests") testsuites.append(suite_node) logfile.write(ET.tostring(testsuites, encoding="unicode")) diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 4145f34ab14..504e4969039 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1451,6 +1451,7 @@ def test_x(): _, dom = run_and_parse(family=xunit_family) root = dom.get_unique_child assert root.tag == "testsuites" + root.assert_attr(name="pytest tests") suite_node = root.get_unique_child assert suite_node.tag == "testsuite"