summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-11-09 17:46:17 (GMT)
committerBarry Warsaw <barry@python.org>2001-11-09 17:46:17 (GMT)
commit75edc6a03331c41473d487853a7768b503f192b0 (patch)
tree4541b3590f1534ad2536d06cecc5f65e31770592 /Lib/test/test_email.py
parent9aa64353984f5ed2d46a605039db32a511db3687 (diff)
downloadcpython-75edc6a03331c41473d487853a7768b503f192b0.zip
cpython-75edc6a03331c41473d487853a7768b503f192b0.tar.gz
cpython-75edc6a03331c41473d487853a7768b503f192b0.tar.bz2
test_formatdate(): A test for email.Utils.formatdate().
Diffstat (limited to 'Lib/test/test_email.py')
-rw-r--r--Lib/test/test_email.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py
index d397c09..1e065e4 100644
--- a/Lib/test/test_email.py
+++ b/Lib/test/test_email.py
@@ -919,6 +919,22 @@ class TestMiscellaneous(unittest.TestCase):
'Utils',
'message_from_file', 'message_from_string'])
+ def test_formatdate(self):
+ now = 1005327232.109884
+ gdate = Utils.formatdate(now)
+ ldate = Utils.formatdate(now, localtime=1)
+ self.assertEqual(gdate, 'Fri, 09 Nov 2001 17:33:52 -0000')
+ # It's a little tougher to test for localtime, but we'll try
+ gtime = time.strptime(gdate.split()[4], '%H:%M:%S')
+ ltime = time.strptime(ldate.split()[4], '%H:%M:%S')
+ zone = ldate.split()[5]
+ offset = int(zone[:3]) * -3600 + int(zone[-2:])
+ if time.daylight and time.localtime(now)[-1]:
+ toff = time.altzone
+ else:
+ toff = time.timezone
+ self.assertEqual(offset, toff)
+
# Test the iterator/generators