[Zodb-checkins] CVS: StandaloneZODB/ZEO/tests - testZEO.py:1.1.2.15

Jeremy Hylton jeremy@zope.com
Thu, 3 Jan 2002 19:43:21 -0500


Update of /cvs-repository/StandaloneZODB/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv29062

Modified Files:
      Tag: ZEO-ZRPC-Dev
	testZEO.py 
Log Message:
Several changes:

Change doc strings to comments so that unittest prints the name of the
test method rather than the first line of the doc string.

Change checkReconnection() so that it catches the currently thrown errors.

Ignore waitpid errors during cleanup.



=== StandaloneZODB/ZEO/tests/testZEO.py 1.1.2.14 => 1.1.2.15 ===
 import os
 import random
+import select
 import socket
 import sys
 import tempfile
@@ -277,19 +278,19 @@
         self.__super_tearDown()
 
     def checkDisconnectionError(self):
-        """Make sure we get a Disconnected when we try to read an
-        object when we're not connected to a storage server and the
-        object is not in the cache.  """
+        # Make sure we get a Disconnected when we try to read an
+        # object when we're not connected to a storage server and the
+        # object is not in the cache.
         self.shutdownServer()
         self._storage = self.openClientStorage('test', 1000, 0)
         self.assertRaises(Disconnected, self._storage.load, 'fredwash', '')
 
     def checkBasicPersistence(self):
-        """Verify cached data persists across client storage instances.
+        # Verify cached data persists across client storage instances.
+
+        # To verify that the cache is being used, the test closes the
+        # server and then starts a new client with the server down.
 
-        To verify that the cache is being used, the test closes the
-        server and then starts a new client with the server down.
-        """
         self._storage = self.openClientStorage('test', 100000, 1)
         oid = self._storage.new_oid()
         obj = MinPO(12)
@@ -303,11 +304,11 @@
         self._storage.close()
 
     def checkRollover(self):
-        """Check that the cache works when the files are swapped.
+        # Check that the cache works when the files are swapped.
 
-        In this case, only one object fits in a cache file.  When the
-        cache files swap, the first object is effectively uncached.
-        """
+        # In this case, only one object fits in a cache file.  When the
+        # cache files swap, the first object is effectively uncached.
+        
         self._storage = self.openClientStorage('test', 1000, 1)
         oid1 = self._storage.new_oid()
         obj1 = MinPO("1" * 500)
@@ -322,9 +323,8 @@
         self._storage.load(oid2, '')
 
     def checkReconnection(self):
-        """Check that the client reconnects when a server restarts."""
+        # Check that the client reconnects when a server restarts.
 
-        from ZEO.ClientStorage import ClientDisconnected
         self._storage = self.openClientStorage()
         oid = self._storage.new_oid()
         obj = MinPO(12)
@@ -337,11 +337,10 @@
         while 1:
             try:
                 revid1 = self._dostore(oid, data=obj)
-            except (ClientDisconnected, thread.error, socket.error), err:
-                get_transaction().abort()
-                time.sleep(0.1)
-            else:
                 break
+            except (Disconnected, select.error, thread.error, socket.error), err:
+                get_transaction().abort()
+                time.sleep(0.1) # XXX how long to sleep
             # XXX This is a bloody pain.  We're placing a heavy burden
             # on users to catch a plethora of exceptions in order to
             # write robust code.  Need to think about implementing
@@ -380,7 +379,10 @@
         if self.running:
             self.running = 0
             self._server.close()
-            os.waitpid(self._pid, 0)
+            try:
+                os.waitpid(self._pid, 0)
+            except os.error:
+                pass
 
 class WindowsConnectionTests(ConnectionTests):
     __super_setUp = StorageTestBase.StorageTestBase.setUp