[Python-checkins] python/nondist/sandbox/datetime test_datetime.py,1.111,1.112

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2003年2月06日 08:32:34 -0800


Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv4898
Modified Files:
	test_datetime.py 
Log Message:
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.
Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v
retrieving revision 1.111
retrieving revision 1.112
diff -C2 -d -r1.111 -r1.112
*** test_datetime.py	5 Feb 2003 22:29:00 -0000	1.111
--- test_datetime.py	6 Feb 2003 16:32:31 -0000	1.112
***************
*** 2258,2273 ****
 
 # 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))
 
 def test_tzinfo_utcnow(self):
--- 2258,2272 ----
 
 # Try to make sure tz= actually does some conversion.
! 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):

AltStyle によって変換されたページ (->オリジナル) /