[Zodb-checkins] CVS: ZODB3/ZEO/tests - testZEO.py:1.41

Guido van Rossum guido@python.org
Tue, 17 Sep 2002 12:44:38 -0400


Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv21673

Modified Files:
	testZEO.py 
Log Message:
In _getAddr(), when we run out of ports, refill the ports list.
Otherwise, when running the tests in an endless loop with "test.py
-L", eventually tests start failing because they're out of ports.


=== ZODB3/ZEO/tests/testZEO.py 1.40 => 1.41 ===
--- ZODB3/ZEO/tests/testZEO.py:1.40	Tue Sep 17 12:05:26 2002
+++ ZODB3/ZEO/tests/testZEO.py	Tue Sep 17 12:44:38 2002
@@ -204,6 +204,10 @@
     def delStorage(self):
         removefs(self.__fs_base)
 
+def _fillports(ports):
+    for i in range(200):
+        ports.append(random.randrange(25000, 30000))
+
 class ConnectionTests(StorageTestBase.StorageTestBase):
     """Tests that explicitly manage the server process.
 
@@ -214,9 +218,7 @@
     __super_tearDown = StorageTestBase.StorageTestBase.tearDown
 
     ports = []
-    for i in range(200):
-        ports.append(random.randrange(25000, 30000))
-    del i
+    _fillports(ports)
 
     def setUp(self):
         """Start a ZEO server using a Unix domain socket
@@ -238,6 +240,8 @@
         self.addr.append(self._getAddr())
 
     def _getAddr(self):
+        if not self.ports:
+            _fillports(self.ports)
         return 'localhost', self.ports.pop()
 
     def openClientStorage(self, cache='', cache_size=200000, wait=1,