From 02c7b8c03d4970421a5170e44c57cbc3cda82827 Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Thu, 7 Mar 2019 12:34:15 +1300 Subject: [PATCH] subunit/run.py: make iso8601 UTC usage python 2/3 compatible In `iso8601/iso8601.py`: if sys.version_info >= (3, 2, 0): UTC = datetime.timezone.utc ... else: class Utc(datetime.tzinfo): ... UTC = Utc() The class `Utc` is only available for python < 3.2.0. Use `UTC` instance instead, which is python 2/3 compatible. Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Noel Power --- python/samba/subunit/run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/samba/subunit/run.py b/python/samba/subunit/run.py index 8f32d46..89ca8a8 100755 --- a/python/samba/subunit/run.py +++ b/python/samba/subunit/run.py @@ -24,7 +24,7 @@ $ python -m samba.subunit.run mylib.tests.test_suite """ -from iso8601.iso8601 import Utc +from iso8601.iso8601 import UTC import datetime import os @@ -184,7 +184,7 @@ class TestProtocolClient(unittest.TestResult): ":param datetime: A datetime.datetime object. """ - time = a_datetime.astimezone(Utc()) + time = a_datetime.astimezone(UTC) self._stream.write("time: %04d-%02d-%02d %02d:%02d:%02d.%06dZ\n" % ( time.year, time.month, time.day, time.hour, time.minute, time.second, time.microsecond)) @@ -458,7 +458,7 @@ class AutoTimingTestResultDecorator(HookedTestResultDecorator): time = self._time if time is not None: return - time = datetime.datetime.utcnow().replace(tzinfo=Utc()) + time = datetime.datetime.utcnow().replace(tzinfo=UTC) self.decorated.time(time) @property -- 2.7.4