diff options
author | Matt Clay <matt@mystile.com> | 2023-05-10 17:07:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 17:07:26 -0700 |
commit | 8f07fda2b5570d37dcf5dfa0606220097cccfb54 (patch) | |
tree | 47f4ea7fa3fb9eeec550afd06c0892803052e79e /lib | |
parent | ab220107d56692cd3bdb10a61a78d5cb6d156025 (diff) | |
download | ansible-8f07fda2b5570d37dcf5dfa0606220097cccfb54.tar.gz |
[stable-2.13] ansible-test - Avoid use of deprecated utcnow (#80750) (#80759)
The timestamps are only used by ansible-test, not the junit callback, so this change only impacts ansible-test.
(cherry picked from commit fd341265d001d4e6545ffb2b7d154340cb1f1931)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/utils/_junit_xml.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ansible/utils/_junit_xml.py b/lib/ansible/utils/_junit_xml.py index 3b958672b7..962fd9f793 100644 --- a/lib/ansible/utils/_junit_xml.py +++ b/lib/ansible/utils/_junit_xml.py @@ -138,6 +138,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.""" @@ -181,7 +185,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: |