Add hostname and timestamp to JUnit XML testsuite tag (#5692)
Add hostname and timestamp to JUnit XML testsuite tag Conflicts: testing/test_junitxml.py
This commit is contained in:
parent
943f4ac236
commit
8b9482e39c
|
@ -0,0 +1 @@
|
||||||
|
JUnit XML now includes a timestamp and hostname in the testsuite tag.
|
|
@ -15,9 +15,11 @@ from __future__ import print_function
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
import py
|
import py
|
||||||
import six
|
import six
|
||||||
|
@ -676,6 +678,8 @@ class LogXML(object):
|
||||||
skipped=self.stats["skipped"],
|
skipped=self.stats["skipped"],
|
||||||
tests=numtests,
|
tests=numtests,
|
||||||
time="%.3f" % suite_time_delta,
|
time="%.3f" % suite_time_delta,
|
||||||
|
timestamp=datetime.fromtimestamp(self.suite_start_time).isoformat(),
|
||||||
|
hostname=platform.node(),
|
||||||
)
|
)
|
||||||
logfile.write(Junit.testsuites([suite_node]).unicode(indent=0))
|
logfile.write(Junit.testsuites([suite_node]).unicode(indent=0))
|
||||||
logfile.close()
|
logfile.close()
|
||||||
|
|
|
@ -4,7 +4,9 @@ from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
@ -145,6 +147,30 @@ class TestPython(object):
|
||||||
node = dom.find_first_by_tag("testsuite")
|
node = dom.find_first_by_tag("testsuite")
|
||||||
node.assert_attr(name="pytest", errors=1, failures=2, skipped=1, tests=5)
|
node.assert_attr(name="pytest", errors=1, failures=2, skipped=1, tests=5)
|
||||||
|
|
||||||
|
def test_hostname_in_xml(self, testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
def test_pass():
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result, dom = runandparse(testdir)
|
||||||
|
node = dom.find_first_by_tag("testsuite")
|
||||||
|
node.assert_attr(hostname=platform.node())
|
||||||
|
|
||||||
|
def test_timestamp_in_xml(self, testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
def test_pass():
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
start_time = datetime.now()
|
||||||
|
result, dom = runandparse(testdir)
|
||||||
|
node = dom.find_first_by_tag("testsuite")
|
||||||
|
timestamp = datetime.strptime(node["timestamp"], "%Y-%m-%dT%H:%M:%S.%f")
|
||||||
|
assert start_time <= timestamp < datetime.now()
|
||||||
|
|
||||||
def test_timing_function(self, testdir):
|
def test_timing_function(self, testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue