Mailing List Archive

python/nondist/sandbox/datetime doc.txt,1.59,1.60 test_datetime.py,1.72,1.73
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv25539

Modified Files:
doc.txt test_datetime.py
Log Message:
Fudged the test suite to avoid provoking the 2.2.2 comparison bug (which
Guido just fixed on the 2.2 maintenance branch, but when this test suite
gets copied into the Zope3 tree it will be run under 2.2.2).


Index: doc.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/doc.txt,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** doc.txt 16 Dec 2002 22:43:05 -0000 1.59
--- doc.txt 16 Dec 2002 22:59:58 -0000 1.60
***************
*** 10,16 ****
and has no wiggle room (TOOWTDI indeed <wink>).

- - The test suite doesn't pass under 2.2.2, due to what Guido tracked
- to a bug in 2.2.2's implementation of __cmp__ for new-style classes.
-
- LaTeXize the docs.

--- 10,13 ----
***************
*** 18,21 ****
--- 15,23 ----
CLOSED
======
+ - The test suite doesn't pass under 2.2.2, due to what Guido tracked
+ to a bug in 2.2.2's implementation of __cmp__ for new-style classes.
+ Later: the test suite grew a version check to avoid provoking this
+ bug under 2.2.2.
+
- What should str() do? It generally acts like a synonym for isoformat()
now. But

Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v
retrieving revision 1.72
retrieving revision 1.73
diff -C2 -d -r1.72 -r1.73
*** test_datetime.py 16 Dec 2002 21:20:43 -0000 1.72
--- test_datetime.py 16 Dec 2002 22:59:59 -0000 1.73
***************
*** 13,16 ****
--- 13,32 ----
from datetime import date, datetime, datetimetz

+
+ # 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)
+
+
#############################################################################
# module tests
***************
*** 1300,1305 ****
self.assertEqual(cmp(t2, t1), 1)

! for badarg in (10, 10L, 34.5, "abc", {}, [], (), date(1, 1, 1),
! datetime(1, 1, 1, 1, 1), timedelta(9)):
self.assertRaises(TypeError, lambda: t1 == badarg)
self.assertRaises(TypeError, lambda: t1 != badarg)
--- 1316,1323 ----
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.assertRaises(TypeError, lambda: t1 == badarg)
self.assertRaises(TypeError, lambda: t1 != badarg)