diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-02-06 16:42:14 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-02-06 16:42:14 (GMT) |
commit | 844076122e5d7a5aeab8089dd2fb91bfd47596a2 (patch) | |
tree | e56aa77c0b349237d620f0984aa91f7e05306b24 /Lib | |
parent | cc1fccbc1c73937ce8b45ba673c63d0230ee4fb5 (diff) | |
download | cpython-844076122e5d7a5aeab8089dd2fb91bfd47596a2.zip cpython-844076122e5d7a5aeab8089dd2fb91bfd47596a2.tar.gz cpython-844076122e5d7a5aeab8089dd2fb91bfd47596a2.tar.bz2 |
SF bug 680864: test_datetime fails for non-unix epoch
Apparently MAC OS 9 doesn't have POSIX-conforming timestamps. A test
fails as a result, but at least for this specific test it's easy enough
to get the POSIX epoch out of it.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_datetime.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index d174f69..712a349 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -2257,18 +2257,17 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase): self.assertRaises(TypeError, meth) # Try to make sure tz= actually does some conversion. - timestamp = 1000000000 # 2001-09-09 01:46:40 UTC, give or take - utc = FixedOffset(0, "utc", 0) - expected = datetime(2001, 9, 9, 1, 46, 40) - got = datetime.utcfromtimestamp(timestamp) - # We don't support leap seconds, but maybe the platfrom insists - # on using them, so don't demand exact equality). - self.failUnless(abs(got - expected) < timedelta(minutes=1)) - - est = FixedOffset(-5*60, "est", 0) - expected -= timedelta(hours=5) - got = datetime.fromtimestamp(timestamp, est).replace(tzinfo=None) - self.failUnless(abs(got - expected) < timedelta(minutes=1)) + timestamp = 1000000000 + utcdatetime = datetime.utcfromtimestamp(timestamp) + # In POSIX (epoch 1970), that's 2001-09-09 01:46:40 UTC, give or take. + # But on some flavor of Mac, it's nowhere near that. So we can't have + # any idea here what time that actually is, we can only test that + # relative changes match. + utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero + tz = FixedOffset(utcoffset, "tz", 0) + expected = utcdatetime + utcoffset + got = datetime.fromtimestamp(timestamp, tz) + self.assertEqual(expected, got.replace(tzinfo=None)) def test_tzinfo_utcnow(self): meth = self.theclass.utcnow |