[tests] use 'datetime.timezone.utc' instead of 'datetime.UTC'

'datetime.UTC' was added in Python 3.11
and is not defined in older versions.
pull/5372/head
Mike Fährmann 6 months ago
parent 4b6f47e571
commit 55e8fdad29
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -238,13 +238,15 @@ class TestFormatter(unittest.TestCase):
self._run_test("{t!d:O2}", "2010-01-01 02:00:00")
def test_offset_local(self):
ts = self.kwdict["dt"].replace(tzinfo=datetime.UTC).timestamp()
ts = self.kwdict["dt"].replace(
tzinfo=datetime.timezone.utc).timestamp()
offset = time.localtime(ts).tm_gmtoff
dt = self.kwdict["dt"] + datetime.timedelta(seconds=offset)
self._run_test("{dt:O}", str(dt))
self._run_test("{dt:Olocal}", str(dt))
ts = self.kwdict["dt_dst"].replace(tzinfo=datetime.UTC).timestamp()
ts = self.kwdict["dt_dst"].replace(
tzinfo=datetime.timezone.utc).timestamp()
offset = time.localtime(ts).tm_gmtoff
dt = self.kwdict["dt_dst"] + datetime.timedelta(seconds=offset)
self._run_test("{dt_dst:O}", str(dt))

Loading…
Cancel
Save