[Zope3-checkins] CVS: Zope3/src/datetime/tests - test_datetime.py:1.11

Tim Peters tim.one@comcast.net
Tue, 31 Dec 2002 23:15:30 -0500


Update of /cvs-repository/Zope3/src/datetime/tests
In directory cvs.zope.org:/tmp/cvs-serv7162/src/datetime/tests

Modified Files:
	test_datetime.py 
Log Message:
The failure of the last-second addition to the timezone coversion test is
understood now:  it can't work.  Added comments explaining why (it's "the
usual"-- unrepresentable hours in local time --but in a slightly different
guise).

Added an optimization to astimezone().  This will pay off more in the C
implementation (which is already optimized to work with offsets as C
ints internally, instead of with timedelta objects; this will let it
replace a datetimetz comparison call with a couple of int operations; in
the Python implementation it trades away a datetimetz comparison call
for a couple of timedelta operations).


=== Zope3/src/datetime/tests/test_datetime.py 1.10 => 1.11 ===
--- Zope3/src/datetime/tests/test_datetime.py:1.10	Tue Dec 31 10:34:50 2002
+++ Zope3/src/datetime/tests/test_datetime.py	Tue Dec 31 23:15:29 2002
@@ -2601,7 +2601,6 @@
     dston = datetimetz(2002, 4, 7, 2)
     dstoff = datetimetz(2002, 10, 27, 2)
 
-
     # Check a time that's inside DST.
     def checkinside(self, dt, tz, utc, dston, dstoff):
         self.assertEqual(dt.dst(), HOUR)
@@ -2701,9 +2700,18 @@
         # hours" don't overlap.
         self.convert_between_tz_and_utc(Eastern, Pacific)
         self.convert_between_tz_and_utc(Pacific, Eastern)
-        # XXX These fail!
-        #self.convert_between_tz_and_utc(Eastern, Central)
-        #self.convert_between_tz_and_utc(Central, Eastern)
+        # OTOH, these fail!  Don't enable them.  The difficulty is that
+        # the edge case tests assume that every hour is representable in
+        # the "utc" class.  This is always true for a fixed-offset tzinfo
+        # class (lke utc_real and utc_fake), but not for Eastern or Central.
+        # For these adjacent DST-aware time zones, the range of time offsets
+        # tested ends up creating hours in the one that aren't representable
+        # in the other.  For the same reason, we would see failures in the
+        # Eastern vs Pacific tests too if we added 3*HOUR to the list of
+        # offset deltas in convert_between_tz_and_utc().
+        #
+        # self.convert_between_tz_and_utc(Eastern, Central)  # can't work
+        # self.convert_between_tz_and_utc(Central, Eastern)  # can't work
 
 
 def test_suite():