[Zope3-checkins]
SVN: Zope3/branches/ZopeX3-3.0/src/zope/xmlpickle/tests/test_xmlpickle.py
Fix Python 2.4 compatibility.
Fred L. Drake, Jr.
fred at zope.com
Wed Jun 23 15:39:09 EDT 2004
Log message for revision 25961:
Fix Python 2.4 compatibility.
Python 2.4 doesn't support the comparison of recursive objects, so we
have to implement the test of pickling/unpickling recursive objects
differently.
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/xmlpickle/tests/test_xmlpickle.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/xmlpickle/tests/test_xmlpickle.py 2004-06-23 19:38:53 UTC (rev 25960)
+++ Zope3/branches/ZopeX3-3.0/src/zope/xmlpickle/tests/test_xmlpickle.py 2004-06-23 19:39:08 UTC (rev 25961)
@@ -15,7 +15,7 @@
$Id$
"""
-
+import pickle
import unittest
from zope.xmlpickle import dumps, loads
@@ -218,14 +218,28 @@
self.__test(complex(1,2))
def test_cycles(self):
+ # Python 2.4 does not support recursive comparisons to the
+ # same extent as Python 2.3, so we test these recursive
+ # structures by comparing the standard pickles of the original
+ # and pickled/unpickled copy. This works for things like
+ # lists and tuples, but could easily break for dictionaries.
+
l = [1, 2 , 3]
l.append(l)
- self.__test(l)
+ xml = dumps(l)
+ newl = loads(xml)
+ p1 = pickle.dumps(l)
+ p2 = pickle.dumps(newl)
+ self.assertEqual(p1, p2)
+
t = l, l
l.append(t)
- self.__test(l)
+ xml = dumps(l)
+ newl = loads(xml)
+ p1 = pickle.dumps(l)
+ p2 = pickle.dumps(newl)
+ self.assertEqual(p1, p2)
-
def test_list(self):
self.__test([])
self.__test([1,2,3])
More information about the Zope3-Checkins
mailing list