summaryrefslogtreecommitdiff
path: root/lib/ansible/utils
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2023-05-10 11:26:49 -0700
committerGitHub <noreply@github.com>2023-05-10 11:26:49 -0700
commitfd341265d001d4e6545ffb2b7d154340cb1f1931 (patch)
treeba59c0d66794708beef6f3315239c5312271d283 /lib/ansible/utils
parent905131fc76a07cf89dbc8d33e7a4910da3f10a16 (diff)
downloadansible-fd341265d001d4e6545ffb2b7d154340cb1f1931.tar.gz
ansible-test - Avoid use of deprecated utcnow (#80750)
The timestamps are only used by ansible-test, not the junit callback, so this change only impacts ansible-test.
Diffstat (limited to 'lib/ansible/utils')
-rw-r--r--lib/ansible/utils/_junit_xml.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ansible/utils/_junit_xml.py b/lib/ansible/utils/_junit_xml.py
index 6b7c80f4cd..8c4dba013e 100644
--- a/lib/ansible/utils/_junit_xml.py
+++ b/lib/ansible/utils/_junit_xml.py
@@ -144,6 +144,10 @@ class TestSuite:
system_out: str | None = None
system_err: str | None = None
+ def __post_init__(self):
+ if self.timestamp and self.timestamp.tzinfo != datetime.timezone.utc:
+ raise ValueError(f'timestamp.tzinfo must be {datetime.timezone.utc!r}')
+
@property
def disabled(self) -> int:
"""The number of disabled test cases."""
@@ -187,7 +191,7 @@ class TestSuite:
skipped=self.skipped,
tests=self.tests,
time=self.time,
- timestamp=self.timestamp.isoformat(timespec='seconds') if self.timestamp else None,
+ timestamp=self.timestamp.replace(tzinfo=None).isoformat(timespec='seconds') if self.timestamp else None,
)
def get_xml_element(self) -> ET.Element: