diff options
author | Barry Warsaw <barry@python.org> | 2001-11-19 16:31:06 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2001-11-19 16:31:06 (GMT) |
commit | 75a40fcc3a57c76b3c844706a45a6a3f1a1e4a73 (patch) | |
tree | 95f2a74ec4f51638e8f5e7e6a558636758993b6b /Lib/test/test_email.py | |
parent | cd45a36959f3a8a74731c7dc25fee95108198e7d (diff) | |
download | cpython-75a40fcc3a57c76b3c844706a45a6a3f1a1e4a73.zip cpython-75a40fcc3a57c76b3c844706a45a6a3f1a1e4a73.tar.gz cpython-75a40fcc3a57c76b3c844706a45a6a3f1a1e4a73.tar.bz2 |
test_formatdate(), test_formatdate_zoneoffsets(): Two changes. First,
use the correct way to test for epoch, by looking at the year
component of gmtime(0). Add clause for Unix epoch and Mac epoch (Tim,
what is Windows epoch?).
Also, get rid of the strptime() test, it was way too problematic given
that strptime() is missing on many platforms and issues with locales.
Instead, simply test that formatdate() gets the numeric timezone
calculation correct for the altzone and timezone.
Diffstat (limited to 'Lib/test/test_email.py')
-rw-r--r-- | Lib/test/test_email.py | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py index 4de0514..356a4ac 100644 --- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -921,12 +921,12 @@ class TestMiscellaneous(unittest.TestCase): def test_formatdate(self): now = 1005327232.109884 - time0 = time.ctime(0) + epoch = time.gmtime(0)[0] # When does the epoch start? - if time0 == 'Wed Dec 31 19:00:00 1969': + if epoch == 1970: # traditional Unix epoch matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000' - elif time0 == 'Fri Jan 1 00:00:00 1904': + elif epoch == 1904: # Mac epoch matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000' else: @@ -934,20 +934,19 @@ class TestMiscellaneous(unittest.TestCase): gdate = Utils.formatdate(now) ldate = Utils.formatdate(now, localtime=1) self.assertEqual(gdate, matchdate) - # It's a little tougher to test for localtime, but we'll try. Skip if - # we don't have strptime(). - if hasattr(time, 'strptime'): - 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) - - def test_parsedate(self): + + def test_formatdate_zoneoffsets(self): + now = 1005327232.109884 + ldate = Utils.formatdate(now, localtime=1) + zone = ldate.split()[5] + offset = int(zone[:3]) * -3600 + int(zone[-2:]) * -60 + if time.daylight and time.localtime(now)[-1]: + toff = time.altzone + else: + toff = time.timezone + self.assertEqual(offset, toff) + + def test_parsedate_none(self): self.assertEqual(Utils.parsedate(''), None) |