parent
60a358fa2d
commit
a43ba78d3b
|
@ -0,0 +1 @@
|
||||||
|
The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
|
|
@ -657,18 +657,17 @@ class LogXML:
|
||||||
)
|
)
|
||||||
logfile.write('<?xml version="1.0" encoding="utf-8"?>')
|
logfile.write('<?xml version="1.0" encoding="utf-8"?>')
|
||||||
|
|
||||||
logfile.write(
|
suite_node = Junit.testsuite(
|
||||||
Junit.testsuite(
|
self._get_global_properties_node(),
|
||||||
self._get_global_properties_node(),
|
[x.to_xml() for x in self.node_reporters_ordered],
|
||||||
[x.to_xml() for x in self.node_reporters_ordered],
|
name=self.suite_name,
|
||||||
name=self.suite_name,
|
errors=self.stats["error"],
|
||||||
errors=self.stats["error"],
|
failures=self.stats["failure"],
|
||||||
failures=self.stats["failure"],
|
skipped=self.stats["skipped"],
|
||||||
skipped=self.stats["skipped"],
|
tests=numtests,
|
||||||
tests=numtests,
|
time="%.3f" % suite_time_delta,
|
||||||
time="%.3f" % suite_time_delta,
|
|
||||||
).unicode(indent=0)
|
|
||||||
)
|
)
|
||||||
|
logfile.write(Junit.testsuites([suite_node]).unicode(indent=0))
|
||||||
logfile.close()
|
logfile.close()
|
||||||
|
|
||||||
def pytest_terminal_summary(self, terminalreporter):
|
def pytest_terminal_summary(self, terminalreporter):
|
||||||
|
|
|
@ -41,6 +41,16 @@ class DomNode:
|
||||||
def _by_tag(self, tag):
|
def _by_tag(self, tag):
|
||||||
return self.__node.getElementsByTagName(tag)
|
return self.__node.getElementsByTagName(tag)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def children(self):
|
||||||
|
return [type(self)(x) for x in self.__node.childNodes]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def get_unique_child(self):
|
||||||
|
children = self.children
|
||||||
|
assert len(children) == 1
|
||||||
|
return children[0]
|
||||||
|
|
||||||
def find_nth_by_tag(self, tag, n):
|
def find_nth_by_tag(self, tag, n):
|
||||||
items = self._by_tag(tag)
|
items = self._by_tag(tag)
|
||||||
try:
|
try:
|
||||||
|
@ -75,7 +85,7 @@ class DomNode:
|
||||||
return self.__node.tagName
|
return self.__node.tagName
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def next_siebling(self):
|
def next_sibling(self):
|
||||||
return type(self)(self.__node.nextSibling)
|
return type(self)(self.__node.nextSibling)
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,11 +394,11 @@ class TestPython:
|
||||||
fnode = tnode.find_first_by_tag("failure")
|
fnode = tnode.find_first_by_tag("failure")
|
||||||
fnode.assert_attr(message="ValueError: 42")
|
fnode.assert_attr(message="ValueError: 42")
|
||||||
assert "ValueError" in fnode.toxml()
|
assert "ValueError" in fnode.toxml()
|
||||||
systemout = fnode.next_siebling
|
systemout = fnode.next_sibling
|
||||||
assert systemout.tag == "system-out"
|
assert systemout.tag == "system-out"
|
||||||
assert "hello-stdout" in systemout.toxml()
|
assert "hello-stdout" in systemout.toxml()
|
||||||
assert "info msg" not in systemout.toxml()
|
assert "info msg" not in systemout.toxml()
|
||||||
systemerr = systemout.next_siebling
|
systemerr = systemout.next_sibling
|
||||||
assert systemerr.tag == "system-err"
|
assert systemerr.tag == "system-err"
|
||||||
assert "hello-stderr" in systemerr.toxml()
|
assert "hello-stderr" in systemerr.toxml()
|
||||||
assert "info msg" not in systemerr.toxml()
|
assert "info msg" not in systemerr.toxml()
|
||||||
|
@ -1094,6 +1104,20 @@ def test_random_report_log_xdist(testdir, monkeypatch):
|
||||||
assert failed == ["test_x[22]"]
|
assert failed == ["test_x[22]"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_root_testsuites_tag(testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
def test_x():
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
_, dom = runandparse(testdir)
|
||||||
|
root = dom.get_unique_child
|
||||||
|
assert root.tag == "testsuites"
|
||||||
|
suite_node = root.get_unique_child
|
||||||
|
assert suite_node.tag == "testsuite"
|
||||||
|
|
||||||
|
|
||||||
def test_runs_twice(testdir):
|
def test_runs_twice(testdir):
|
||||||
f = testdir.makepyfile(
|
f = testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue