import sys
import unittest
-from testtools.compat import _format_exc_info, str_is_unicode, _u
+from testtools.compat import all, _format_exc_info, str_is_unicode, _u
+
+# 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()
class TestResult(unittest.TestResult):
time() method.
"""
if self.__now is None:
- return datetime.datetime.now()
+ return datetime.datetime.now(utc)
else:
return self.__now
def stopTestRun(self):
return self._dispatch('stopTestRun')
+ def time(self, a_datetime):
+ return self._dispatch('time', a_datetime)
+
def done(self):
return self._dispatch('done')