[Zodb-checkins] CVS: ZODB3/ZODB/tests - IteratorStorage.py:1.16

Barry Warsaw barry@wooz.org
Mon, 20 Jan 2003 14:09:07 -0500


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv1169

Modified Files:
	IteratorStorage.py 
Log Message:
checkIterationIntraTransaction(): A test for doing iteration while in
the middle of a transaction.  This test isn't totally helpful in its
own right, but run it with logging and you'll see the bogus warning
(before the fix is applied).


=== ZODB3/ZODB/tests/IteratorStorage.py 1.15 => 1.16 ===
--- ZODB3/ZODB/tests/IteratorStorage.py:1.15	Fri Jan  3 17:07:45 2003
+++ ZODB3/ZODB/tests/IteratorStorage.py	Mon Jan 20 14:09:04 2003
@@ -18,7 +18,7 @@
 """
 
 from ZODB.tests.MinPO import MinPO
-from ZODB.tests.StorageTestBase import zodb_unpickle
+from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
 from ZODB.utils import U64, p64
 from ZODB.Transaction import Transaction
 
@@ -125,6 +125,27 @@
             self.assertEqual(txn._extension, {})
             count +=1
         self.assertEqual(count, 1)
+
+    def checkIterationIntraTransaction(self):
+        # XXX try this test with logging enabled.  If you see something like
+        #
+        # ZODB FS FS21 warn: FileStorageTests.fs truncated, possibly due to
+        # damaged records at 4
+        #
+        # Then the code in FileIterator.next() hasn't yet been fixed.
+        oid = self._storage.new_oid()
+        t = Transaction()
+        data = zodb_pickle(MinPO(0))
+        try:
+            self._storage.tpc_begin(t)
+            self._storage.store(oid, '\0'*8, data, '', t)
+            self._storage.tpc_vote(t)
+            # Don't do tpc_finish yet
+            it = self._storage.iterator()
+            for x in it:
+                pass
+        finally:
+            self._storage.tpc_finish(t)
 
 
 class ExtendedIteratorStorage(IteratorCompare):