[Python-checkins] python/dist/src/Lib/test test_datetime.py,1.38,1.39

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Fri, 07 Feb 2003 19:46:33 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv13463/Lib/test

Modified Files:
	test_datetime.py 
Log Message:
The Python implementation of datetime was changed in ways that no longer
tickle the 2.2.2 __cmp__ bug test_datetime used to tickle, so the
workarounds for that bug no longer make sense in the test suite (which I'm
still trying to keep as closely in synch as possible with Zope3's
version).


Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** test_datetime.py	7 Feb 2003 22:50:26 -0000	1.38
--- test_datetime.py	8 Feb 2003 03:46:31 -0000	1.39
***************
*** 23,39 ****
  assert len(pickle_choices) == 2*2*3
  
! # XXX The test suite uncovered a bug in Python 2.2.2:  if x and y are
! # XXX instances of new-style classes (like date and time) that both
! # XXX define __cmp__, and x is compared to y, and one of the __cmp__
! # XXX implementations raises an exception, the exception can get dropped
! # XXX on the floor when it occurs, and pop up again at some "random" time
! # XXX later (it depends on when the next opcode gets executed that
! # XXX bothers to check).  There isn't a workaround for this, so instead
! # XXX we disable the parts of the tests that trigger it unless
! # XXX CMP_BUG_FIXED is true.  The bug is still there, we simply avoid
! # XXX provoking it here.
! # XXX Guido checked into a fix that will go into 2.2.3.  The bug was
! # XXX already fixed in 2.3 CVS via a different means.
! CMP_BUG_FIXED = sys.version_info >= (2, 2, 3)
  
  
--- 23,29 ----
  assert len(pickle_choices) == 2*2*3
  
! # An arbitrary collection of objects of non-datetime types, for testing
! # mixed-type comparisons.
! OTHERSTUFF = (10, 10L, 34.5, "abc", {}, [], ())
  
  
***************
*** 344,349 ****
              self.assertEqual(cmp(t2, t1), 1)
  
!         badargs = 10, 10L, 34.5, "abc", {}, [], ()
!         for badarg in badargs:
              self.assertEqual(t1 == badarg, False)
              self.assertEqual(t1 != badarg, True)
--- 334,338 ----
              self.assertEqual(cmp(t2, t1), 1)
  
!         for badarg in OTHERSTUFF:
              self.assertEqual(t1 == badarg, False)
              self.assertEqual(t1 != badarg, True)
***************
*** 351,355 ****
              self.assertEqual(badarg != t1, True)
  
-         for badarg in badargs:
              self.assertRaises(TypeError, lambda: t1 <= badarg)
              self.assertRaises(TypeError, lambda: t1 < badarg)
--- 340,343 ----
***************
*** 899,904 ****
              self.assertEqual(cmp(t2, t1), 1)
  
!         badargs = 10, 10L, 34.5, "abc", {}, [], ()
!         for badarg in badargs:
              self.assertEqual(t1 == badarg, False)
              self.assertEqual(t1 != badarg, True)
--- 887,891 ----
              self.assertEqual(cmp(t2, t1), 1)
  
!         for badarg in OTHERSTUFF:
              self.assertEqual(t1 == badarg, False)
              self.assertEqual(t1 != badarg, True)
***************
*** 906,910 ****
              self.assertEqual(badarg != t1, True)
  
-         for badarg in badargs:
              self.assertRaises(TypeError, lambda: t1 < badarg)
              self.assertRaises(TypeError, lambda: t1 > badarg)
--- 893,896 ----
***************
*** 1476,1484 ****
              self.assertEqual(cmp(t2, t1), 1)
  
!         badargs = (10, 10L, 34.5, "abc", {}, [], ())
!         if CMP_BUG_FIXED:
!             badargs += (date(1, 1, 1), datetime(1, 1, 1, 1, 1), timedelta(9))
! 
!         for badarg in badargs:
              self.assertEqual(t1 == badarg, False)
              self.assertEqual(t1 != badarg, True)
--- 1462,1466 ----
              self.assertEqual(cmp(t2, t1), 1)
  
!         for badarg in OTHERSTUFF:
              self.assertEqual(t1 == badarg, False)
              self.assertEqual(t1 != badarg, True)
***************
*** 1486,1490 ****
              self.assertEqual(badarg != t1, True)
  
-         for badarg in badargs:
              self.assertRaises(TypeError, lambda: t1 <= badarg)
              self.assertRaises(TypeError, lambda: t1 < badarg)
--- 1468,1471 ----
***************
*** 2008,2014 ****
          t2 = t2.replace(tzinfo=FixedOffset(None, ""))
          self.assertEqual(t1, t2)
!         if CMP_BUG_FIXED:
!             t2 = t2.replace(tzinfo=FixedOffset(0, ""))
!             self.assertRaises(TypeError, lambda: t1 == t2)
  
          # In time w/ identical tzinfo objects, utcoffset is ignored.
--- 1989,1994 ----
          t2 = t2.replace(tzinfo=FixedOffset(None, ""))
          self.assertEqual(t1, t2)
!         t2 = t2.replace(tzinfo=FixedOffset(0, ""))
!         self.assertRaises(TypeError, lambda: t1 == t2)
  
          # In time w/ identical tzinfo objects, utcoffset is ignored.
***************
*** 2592,2598 ****
          t2 = t2.replace(tzinfo=FixedOffset(None, ""))
          self.assertEqual(t1, t2)
!         if CMP_BUG_FIXED:
!             t2 = t2.replace(tzinfo=FixedOffset(0, ""))
!             self.assertRaises(TypeError, lambda: t1 == t2)
  
          # In datetime w/ identical tzinfo objects, utcoffset is ignored.
--- 2572,2577 ----
          t2 = t2.replace(tzinfo=FixedOffset(None, ""))
          self.assertEqual(t1, t2)
!         t2 = t2.replace(tzinfo=FixedOffset(0, ""))
!         self.assertRaises(TypeError, lambda: t1 == t2)
  
          # In datetime w/ identical tzinfo objects, utcoffset is ignored.