[Zope3-checkins] CVS: Zope3/src/zodb/storage/tests - undo.py:1.2.8.2 recovery.py:1.3.4.2 iterator.py:1.3.4.3
Jeremy Hylton
jeremy@zope.com
Wed, 5 Feb 2003 15:58:59 -0500
Update of /cvs-repository/Zope3/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv29014/storage/tests
Modified Files:
Tag: storage-interface-branch
undo.py recovery.py iterator.py
Log Message:
Change iterator() implementation for FileStorage to use generators.
=== Zope3/src/zodb/storage/tests/undo.py 1.2.8.1 => 1.2.8.2 ===
--- Zope3/src/zodb/storage/tests/undo.py:1.2.8.1 Wed Feb 5 12:30:06 2003
+++ Zope3/src/zodb/storage/tests/undo.py Wed Feb 5 15:58:26 2003
@@ -592,13 +592,13 @@
# OBJECTS * BATCHES modifications, followed by
# BATCHES undos
- iter = s.iterator()
+ fsiter = iter(s.iterator())
offset = 0
eq = self.assertEqual
for i in range(BATCHES):
- txn = iter[offset]
+ txn = fsiter.next()
offset += 1
tid = p64(i + 1)
@@ -611,12 +611,12 @@
eq(L1, L2)
for i in range(BATCHES * OBJECTS):
- txn = iter[offset]
+ txn = fsiter.next()
offset += 1
eq(len([rec for rec in txn if rec.data_txn is None]), 1)
for i in range(BATCHES):
- txn = iter[offset]
+ txn = fsiter.next()
offset += 1
# The undos are performed in reverse order.
@@ -628,4 +628,4 @@
L2.sort()
eq(L1, L2)
- self.assertRaises(IndexError, iter.__getitem__, offset)
+ self.assertRaises(StopIteration, fsiter.next)
=== Zope3/src/zodb/storage/tests/recovery.py 1.3.4.1 => 1.3.4.2 ===
--- Zope3/src/zodb/storage/tests/recovery.py:1.3.4.1 Wed Feb 5 12:30:06 2003
+++ Zope3/src/zodb/storage/tests/recovery.py Wed Feb 5 15:58:26 2003
@@ -68,11 +68,12 @@
# with None for its data attribute, because we've undone the
# object.
for s in self._storage, self._dst:
- iter = s.iterator()
- for trans in iter:
+ siter = s.iterator()
+ for trans in siter:
pass # iterate until we get the last one
- data = trans[0]
- self.assertRaises(IndexError, lambda i, t=trans: t[i], 1)
+ txniter = iter(trans)
+ data = txniter.next()
+ self.assertRaises(StopIteration, txniter.next)
self.assertEqual(data.oid, oid)
self.assertEqual(data.data, None)
=== Zope3/src/zodb/storage/tests/iterator.py 1.3.4.2 => 1.3.4.3 ===
--- Zope3/src/zodb/storage/tests/iterator.py:1.3.4.2 Wed Feb 5 12:30:06 2003
+++ Zope3/src/zodb/storage/tests/iterator.py Wed Feb 5 15:58:26 2003
@@ -39,7 +39,6 @@
val += 1
eq(val, val0 + len(revids))
-
class IteratorStorage(IteratorCompare):
def checkSimpleIteration(self):
# Store a bunch of revisions of a single object
@@ -50,13 +49,14 @@
# Now iterate over all the transactions and compare carefully
txniter = self._storage.iterator()
self.iter_verify(txniter, [revid1, revid2, revid3], 11)
+ txniter.close()
def checkClose(self):
self._oid = oid = self._storage.newObjectId()
revid1 = self._dostore(oid, data=MinPO(11))
txniter = self._storage.iterator()
txniter.close()
- self.assertRaises(IOError, txniter.__getitem__, 0)
+ self.assertRaises(IOError, iter(txniter).next)
def checkVersionIterator(self):
if not IUndoStorage.isImplementedBy(self._storage):
@@ -170,22 +170,20 @@
eq = self.assertEqual
iter1 = storage1.iterator()
iter2 = storage2.iterator()
- for txn1, txn2 in zip(iter1, iter2):
+ L1 = list(iter1)
+ L2 = list(iter2)
+ eq(len(L1), len(L2))
+ for txn1, txn2 in zip(L1, L2):
eq(txn1.tid, txn2.tid)
eq(txn1.status, txn2.status)
eq(txn1.user, txn2.user)
eq(txn1.description, txn2.description)
eq(txn1._extension, txn2._extension)
- for rec1, rec2 in zip(txn1, txn2):
+ L1 = list(txn1)
+ L2 = list(txn2)
+ eq(len(L1), len(L2))
+ for rec1, rec2 in zip(L1, L2):
eq(rec1.oid, rec2.oid)
eq(rec1.serial, rec2.serial)
eq(rec1.version, rec2.version)
eq(rec1.data, rec2.data)
- # Make sure there are no more records left in rec1 and rec2,
- # meaning they were the same length.
- self.assertRaises(IndexError, txn1.next)
- self.assertRaises(IndexError, txn2.next)
- # Make sure ther are no more records left in txn1 and txn2, meaning
- # they were the same length
- self.assertRaises(IndexError, iter1.next)
- self.assertRaises(IndexError, iter2.next)