diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2019-03-07 12:34:15 +1300 |
---|---|---|
committer | Noel Power <npower@samba.org> | 2019-03-07 12:01:25 +0000 |
commit | 02c7b8c03d4970421a5170e44c57cbc3cda82827 (patch) | |
tree | 1c7f7cdd3de4e8568c572be968ba17d4b091c78a /python | |
parent | 8b18da27cf261b0283fe66d2b827cab542488ac7 (diff) | |
download | samba-02c7b8c03d4970421a5170e44c57cbc3cda82827.tar.gz |
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 <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Diffstat (limited to 'python')
-rwxr-xr-x | python/samba/subunit/run.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/python/samba/subunit/run.py b/python/samba/subunit/run.py index 8f32d46ef49..89ca8a8050b 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 |