junitxml: add timezone to testsuite timestamp (#12491)
Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io> Co-authored-by: Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>
This commit is contained in:
parent
f74e947c1f
commit
0ed2d79457
1
AUTHORS
1
AUTHORS
|
@ -213,6 +213,7 @@ Jordan Guymon
|
||||||
Jordan Moldow
|
Jordan Moldow
|
||||||
Jordan Speicher
|
Jordan Speicher
|
||||||
Joseph Hunkeler
|
Joseph Hunkeler
|
||||||
|
Joseph Sawaya
|
||||||
Josh Karpel
|
Josh Karpel
|
||||||
Joshua Bronson
|
Joshua Bronson
|
||||||
Jurko Gospodnetić
|
Jurko Gospodnetić
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Added timezone information to the testsuite timestamp in the JUnit XML report.
|
|
@ -11,6 +11,7 @@ https://github.com/jenkinsci/xunit-plugin/blob/master/src/main/resources/org/jen
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from datetime import timezone
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
@ -664,7 +665,9 @@ class LogXML:
|
||||||
skipped=str(self.stats["skipped"]),
|
skipped=str(self.stats["skipped"]),
|
||||||
tests=str(numtests),
|
tests=str(numtests),
|
||||||
time=f"{suite_time_delta:.3f}",
|
time=f"{suite_time_delta:.3f}",
|
||||||
timestamp=datetime.fromtimestamp(self.suite_start_time).isoformat(),
|
timestamp=datetime.fromtimestamp(self.suite_start_time, timezone.utc)
|
||||||
|
.astimezone()
|
||||||
|
.isoformat(),
|
||||||
hostname=platform.node(),
|
hostname=platform.node(),
|
||||||
)
|
)
|
||||||
global_properties = self._get_global_properties_node()
|
global_properties = self._get_global_properties_node()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from datetime import timezone
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import platform
|
import platform
|
||||||
|
@ -218,11 +219,11 @@ class TestPython:
|
||||||
pass
|
pass
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
start_time = datetime.now()
|
start_time = datetime.now(timezone.utc)
|
||||||
result, dom = run_and_parse(family=xunit_family)
|
result, dom = run_and_parse(family=xunit_family)
|
||||||
node = dom.find_first_by_tag("testsuite")
|
node = dom.find_first_by_tag("testsuite")
|
||||||
timestamp = datetime.strptime(node["timestamp"], "%Y-%m-%dT%H:%M:%S.%f")
|
timestamp = datetime.strptime(node["timestamp"], "%Y-%m-%dT%H:%M:%S.%f%z")
|
||||||
assert start_time <= timestamp < datetime.now()
|
assert start_time <= timestamp < datetime.now(timezone.utc)
|
||||||
|
|
||||||
def test_timing_function(
|
def test_timing_function(
|
||||||
self, pytester: Pytester, run_and_parse: RunAndParse, mock_timing
|
self, pytester: Pytester, run_and_parse: RunAndParse, mock_timing
|
||||||
|
|
Loading…
Reference in New Issue