test_formatdate(): A test that has a mild hope of working on Mac,

which has a different epoch than *nix.  Jack may need to twiddle the
details.
This commit is contained in:
Barry Warsaw 2001-11-18 23:15:58 +00:00
parent 69ab5836ae
commit 7a1bea64f8
1 changed files with 11 additions and 1 deletions

View File

@ -921,9 +921,19 @@ class TestMiscellaneous(unittest.TestCase):
def test_formatdate(self): def test_formatdate(self):
now = 1005327232.109884 now = 1005327232.109884
time0 = time.ctime(0)
# When does the epoch start?
if time0 == 'Wed Dec 31 19:00:00 1969':
# traditional Unix epoch
matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000'
elif time0 == 'Fri Jan 1 00:00:00 1904':
# Mac epoch
matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000'
else:
matchdate = "I don't understand your epoch"
gdate = Utils.formatdate(now) gdate = Utils.formatdate(now)
ldate = Utils.formatdate(now, localtime=1) ldate = Utils.formatdate(now, localtime=1)
self.assertEqual(gdate, 'Fri, 09 Nov 2001 17:33:52 -0000') self.assertEqual(gdate, matchdate)
# It's a little tougher to test for localtime, but we'll try. Skip if # It's a little tougher to test for localtime, but we'll try. Skip if
# we don't have strptime(). # we don't have strptime().
if hasattr(time, 'strptime'): if hasattr(time, 'strptime'):