[PATCH 28/55] Import UTC definition from utc8601 module.

Jelmer Vernooij jelmer at samba.org
Fri Feb 6 12:04:00 MST 2015


Change-Id: I3ccd81090c4721b161aff272100aa71bc2f17055
Signed-off-by: Jelmer Vernooij <jelmer at samba.org>
---
 python/samba/subunit/__init__.py | 21 ---------------------
 python/samba/subunit/run.py      |  6 +++---
 2 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/python/samba/subunit/__init__.py b/python/samba/subunit/__init__.py
index bd320fd..ab55ace 100644
--- a/python/samba/subunit/__init__.py
+++ b/python/samba/subunit/__init__.py
@@ -17,7 +17,6 @@
 
 """Subunit test protocol."""
 
-import datetime
 import unittest
 
 
@@ -27,26 +26,6 @@ PROGRESS_PUSH = 2
 PROGRESS_POP = 3
 
 
-# From http://docs.python.org/library/datetime.html
-_ZERO = datetime.timedelta(0)
-
-# A UTC class.
-
-class UTC(datetime.tzinfo):
-    """UTC"""
-
-    def utcoffset(self, dt):
-        return _ZERO
-
-    def tzname(self, dt):
-        return "UTC"
-
-    def dst(self, dt):
-        return _ZERO
-
-utc = UTC()
-
-
 def RemoteError(description=""):
     return (Exception, Exception(description), None)
 
diff --git a/python/samba/subunit/run.py b/python/samba/subunit/run.py
index 0eb2913..cde6feb 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 samba.subunit import UTC
+from iso8601.iso8601 import Utc
 
 import datetime
 import os
@@ -189,7 +189,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))
@@ -471,7 +471,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.1.4



More information about the samba-technical mailing list