Skip to content

Commit 7746f4f

Browse files
Alcaresmaugunicoddemus
authored
Add name attribute to testsuites root tag in junitxml (#13404)
Fixes #12736 --------- Co-authored-by: maugu <[email protected]> Co-authored-by: Bruno Oliveira <[email protected]>
1 parent cbee8a5 commit 7746f4f

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ Manuel Krebber
275275
Marc Mueller
276276
Marc Schlaich
277277
Marcelo Duarte Trevisani
278+
Marcin Augustynów
278279
Marcin Bachry
279280
Marc Bresson
280281
Marco Gorelli

changelog/12736.improvement.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Added a new attribute `name` with the fixed value `"pytest tests"` to the root tag `testsuites` of the junit-xml generated by pytest.
2+
3+
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.

src/_pytest/junitxml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ def pytest_sessionfinish(self) -> None:
670670
for node_reporter in self.node_reporters_ordered:
671671
suite_node.append(node_reporter.to_xml())
672672
testsuites = ET.Element("testsuites")
673+
testsuites.set("name", "pytest tests")
673674
testsuites.append(suite_node)
674675
logfile.write(ET.tostring(testsuites, encoding="unicode"))
675676

testing/test_junitxml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ def test_x():
14511451
_, dom = run_and_parse(family=xunit_family)
14521452
root = dom.get_unique_child
14531453
assert root.tag == "testsuites"
1454+
root.assert_attr(name="pytest tests")
14541455
suite_node = root.get_unique_child
14551456
assert suite_node.tag == "testsuite"
14561457

0 commit comments

Comments
 (0)