summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2011-04-26 19:26:41 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2011-04-26 19:26:41 (GMT)
commit37eb3387a4f24eb25ed977b0c4e25f22886d49f6 (patch)
tree21ad884e88b1525c31b8b0ed367e450e323ef986 /Lib/test/test_logging.py
parent373baef1ebd86e4f8f4d3a426163a74cc4cfb713 (diff)
downloadcpython-37eb3387a4f24eb25ed977b0c4e25f22886d49f6.zip
cpython-37eb3387a4f24eb25ed977b0c4e25f22886d49f6.tar.gz
cpython-37eb3387a4f24eb25ed977b0c4e25f22886d49f6.tar.bz2
Refined time test in test_logging.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 813e62a..a93338b 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -43,6 +43,7 @@ import tempfile
from test.support import captured_stdout, run_with_locale, run_unittest, patch
from test.support import TestHandler, Matcher
import textwrap
+import time
import unittest
import warnings
import weakref
@@ -2190,6 +2191,18 @@ class QueueHandlerTest(BaseTest):
self.assertTrue(handler.matches(levelno=logging.ERROR, message='2'))
self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='3'))
+ZERO = datetime.timedelta(0)
+
+class UTC(datetime.tzinfo):
+ def utcoffset(self, dt):
+ return ZERO
+
+ dst = utcoffset
+
+ def tzname(self, dt):
+ return 'UTC'
+
+utc = UTC()
class FormatterTest(unittest.TestCase):
def setUp(self):
@@ -2268,9 +2281,11 @@ class FormatterTest(unittest.TestCase):
def test_time(self):
r = self.get_record()
- r.created = 735375780.0 # 21 April 1993 08:03:00
+ dt = datetime.datetime(1993,4,21,8,3,0,0,utc)
+ r.created = time.mktime(dt.utctimetuple())
r.msecs = 123
f = logging.Formatter('%(asctime)s %(message)s')
+ f.converter = time.gmtime
self.assertEqual(f.formatTime(r), '1993-04-21 08:03:00,123')
self.assertEqual(f.formatTime(r, '%Y:%d'), '1993:21')
f.format(r)