parent
29e336bd9b
commit
1ce45a6f67
|
@ -0,0 +1 @@
|
|||
JUnit XML now includes a timestamp and hostname in the testsuite tag.
|
|
@ -10,9 +10,11 @@ src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
|
|||
"""
|
||||
import functools
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
import py
|
||||
|
||||
|
@ -666,6 +668,8 @@ class LogXML:
|
|||
skipped=self.stats["skipped"],
|
||||
tests=numtests,
|
||||
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.close()
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
import platform
|
||||
from datetime import datetime
|
||||
from xml.dom import minidom
|
||||
|
||||
import py
|
||||
|
@ -139,6 +141,30 @@ class TestPython:
|
|||
node = dom.find_first_by_tag("testsuite")
|
||||
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):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue