[Zope-CVS] CVS: Products/AdaptableStorage/tests - testASStorage.py:1.9

Shane Hathaway shane@zope.com
Fri, 17 Jan 2003 22:34:21 -0500


Update of /cvs-repository/Products/AdaptableStorage/tests
In directory cvs.zope.org:/tmp/cvs-serv4964/tests

Modified Files:
	testASStorage.py 
Log Message:
Made the remainder pickler properly restore cyclic references to
the persistent object.  Until now, it accidentally made internal
copies of the object.


=== Products/AdaptableStorage/tests/testASStorage.py 1.8 => 1.9 ===
--- Products/AdaptableStorage/tests/testASStorage.py:1.8	Fri Jan 10 14:02:16 2003
+++ Products/AdaptableStorage/tests/testASStorage.py	Fri Jan 17 22:33:49 2003
@@ -257,6 +257,34 @@
             conn1.close()
 
 
+    def testRemainderCyclicReferenceRestoration(self):
+        # test whether the remainder pickler properly stores cyclic references
+        # back to the object itself.
+        ob1 = PersistentMapping()
+        ob1.myself = ob1
+
+        dummy = PersistentMapping()
+        dummy.strdata = ''
+
+        conn1 = self.db.open()
+        try:
+            root = conn1.root()
+            get_transaction().begin()
+            root['TestRoot'] = dummy
+            root['TestRoot2'] = ob1
+            get_transaction().commit()
+
+            conn2 = self.db.open()
+            try:
+                ob2 = conn2.root()['TestRoot2']
+                self.assert_(ob2.myself is ob2)
+                self.assert_(ob2 is not ob1)  # Verify it didn't cheat somehow
+            finally:
+                conn2.close()
+        finally:
+            conn1.close()
+
+
 if __name__ == '__main__':
     unittest.main()