test_formatdate(): Don't do the localtime test if we don't have

strptime() -- I'm too lazy to code it otherwise.
This commit is contained in:
Barry Warsaw 2001-11-09 19:30:58 +00:00
parent 114486701a
commit 7edd71a9f5
1 changed files with 12 additions and 10 deletions

View File

@ -924,16 +924,18 @@ class TestMiscellaneous(unittest.TestCase):
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, 'Fri, 09 Nov 2001 17:33:52 -0000')
# It's a little tougher to test for localtime, but we'll try # It's a little tougher to test for localtime, but we'll try. Skip if
gtime = time.strptime(gdate.split()[4], '%H:%M:%S') # we don't have strptime().
ltime = time.strptime(ldate.split()[4], '%H:%M:%S') if hasattr(time, 'striptime'):
zone = ldate.split()[5] gtime = time.strptime(gdate.split()[4], '%H:%M:%S')
offset = int(zone[:3]) * -3600 + int(zone[-2:]) ltime = time.strptime(ldate.split()[4], '%H:%M:%S')
if time.daylight and time.localtime(now)[-1]: zone = ldate.split()[5]
toff = time.altzone offset = int(zone[:3]) * -3600 + int(zone[-2:])
else: if time.daylight and time.localtime(now)[-1]:
toff = time.timezone toff = time.altzone
self.assertEqual(offset, toff) else:
toff = time.timezone
self.assertEqual(offset, toff)