[Zope-Checkins] CVS: StandaloneZODB/ZODB/tests - MTStorage.py:1.1.2.4

Jeremy Hylton jeremy@zope.com
Tue, 8 Jan 2002 10:57:46 -0500


Update of /cvs-repository/StandaloneZODB/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv1374

Modified Files:
      Tag: Standby-branch
	MTStorage.py 
Log Message:
Make ExtStorageClientThread more robust in several ways.

Get the list of possible methods by dir() on the class, which will
work for Python 2.1 and 2.2.

Supply arguments to undoLog() just in case the storage doesn't use
BaseStorage.

Catch AttributeError on attempt to use iterator() method.  This is a
bit crude, but it's hard to tell that ZEO ClientStorage has, say,
loadSerial() and not iterator().  The storage object used for testing
ZEO is a wrapper with a getattr hook.



=== StandaloneZODB/ZODB/tests/MTStorage.py 1.1.2.3 => 1.1.2.4 ===
 
     def run(self):
-        ops = [getattr(self, meth) for meth in dir(self)
-               if meth.startswith('do_') and hasattr(self.storage, meth[3:])]
+        # pick some other storage ops to execute
+        ops = [getattr(self, meth) for meth in dir(ExtStorageClientThread)
+               if meth.startswith('do_')]
+        assert ops, "Didn't find an storage ops in %s" % self.storage
         # do a store to guarantee there's at least one oid in self.oids
         self.dostore(0)
 
@@ -147,10 +149,15 @@
         self.storage.modifiedInVersion(oid)
 
     def do_undoLog(self):
-        self.storage.undoLog()
+        self.storage.undoLog(0, -20)
 
     def do_iterator(self):
-        iter = self.storage.iterator()
+        try:
+            iter = self.storage.iterator()
+        except AttributeError:
+            # XXX It's hard to detect that a ZEO ClientStorage
+            # doesn't have this method, but does have all the others.
+            return
         for obj in iter:
             pass