[ZODB-Dev] Minor fixes to ZODB/tests

Christian Reis kiko at async.com.br
Thu May 8 17:53:41 EDT 2003


Is anybody against me fixing up TransactionalUndoStorage.py and friends
in ZODB/tests/, as follows? Some old cruft makes testFileStorage.py not
work for me.

The fix to MinPO.py allows it to be run standalone as a sanity check
(python minPO.py) -- Persistence hasn't been hacked into sys.modules
there yet.

Index: MinPO.py
===================================================================
RCS file: /cvs-repository/ZODB3/ZODB/tests/MinPO.py,v
retrieving revision 1.3
diff -u -r1.3 MinPO.py
--- MinPO.py	6 Dec 2002 00:00:53 -0000	1.3
+++ MinPO.py	8 May 2003 19:50:40 -0000
@@ -13,7 +13,7 @@
 ##############################################################################
 """A minimal persistent object to use for tests"""
 
-from Persistence import Persistent
+from ZODB import Persistent
 
 class MinPO(Persistent):
     def __init__(self, value=None):
Index: TransactionalUndoStorage.py
===================================================================
RCS file: /cvs-repository/ZODB3/ZODB/tests/TransactionalUndoStorage.py,v
retrieving revision 1.29
diff -u -r1.29 TransactionalUndoStorage.py
--- TransactionalUndoStorage.py	8 May 2003 18:48:49 -0000	1.29
+++ TransactionalUndoStorage.py	8 May 2003 19:50:40 -0000
@@ -673,15 +673,14 @@
         for i in range(BATCHES):
             t = Transaction()
             tid = p64(i + 1)
-            s.tpcBegin(t, tid)
+            s.tpc_begin(t, tid)
             for j in range(OBJECTS):
-                oid = s.newObjectId()
+                oid = s.new_oid()
                 obj = MinPO(i * OBJECTS + j)
-                data, refs = zodb_pickle(obj)
-                revid = s.store(oid, None, data, refs, '', t)
+                revid = s.store(oid, None, zodb_pickle(obj), '', t)
                 orig.append((tid, oid, revid))
-            s.tpcVote(t)
-            s.tpcFinish(t)
+            s.tpc_vote(t)
+            s.tpc_finish(t)
 
         i = 0
         for tid, oid, revid in orig:
@@ -694,13 +693,13 @@
         def undo(i):
             info = s.undoInfo()
             t = Transaction()
-            s.tpcBegin(t)
+            s.tpc_begin(t)
             base = i * OBJECTS + i
             for j in range(OBJECTS):
                 tid = info[base + j]['id']
-                s.undo(tid, t)
-            s.tpcVote(t)
-            s.tpcFinish(t)
+                s.transactionalUndo(tid, t)
+            s.tpc_vote(t)
+            s.tpc_finish(t)
 
         for i in range(BATCHES):
             undo(i)
@@ -710,7 +709,7 @@
         #     OBJECTS * BATCHES modifications, followed by
         #     BATCHES undos
 
-        fsiter = iter(s.iterator())
+        fsiter = s.iterator()
         offset = 0
 
         eq = self.assertEqual
@@ -746,7 +745,15 @@
             L2.sort()
             eq(L1, L2)
 
-        self.assertRaises(StopIteration, fsiter.next)
+        # Python2.1 check
+        if not globals().has_key("StopIteration"):
+            StopIteration = IndexError
+
+        try:
+            fsiter.next()
+            raise AssertionError
+        except (IndexError, StopIteration):
+            pass
 
     def checkTransactionalUndoIterator(self):
         # check that data_txn set in iterator makes sense
Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL



More information about the ZODB-Dev mailing list