[Zodb-checkins] SVN: ZODB/trunk/src/ZEO/tests/ Refactored a test helper to make it a little more self documenting.

Jim Fulton jim at zope.com
Fri Jan 2 16:53:34 EST 2009


Log message for revision 94462:
  Refactored a test helper to make it a little more self documenting.
  

Changed:
  U   ZODB/trunk/src/ZEO/tests/ConnectionTests.py
  U   ZODB/trunk/src/ZEO/tests/forker.py
  U   ZODB/trunk/src/ZEO/tests/testZEO.py

-=-
Modified: ZODB/trunk/src/ZEO/tests/ConnectionTests.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/ConnectionTests.py	2009-01-02 21:22:39 UTC (rev 94461)
+++ ZODB/trunk/src/ZEO/tests/ConnectionTests.py	2009-01-02 21:53:34 UTC (rev 94462)
@@ -640,6 +640,7 @@
         revid = self._dostore(oid)
         revid = self._dostore(oid, revid)
         forker.wait_until(
+            "Client has seen all of the transactions from the server",
             lambda :
             perstorage.lastTransaction() == self._storage.lastTransaction()
             )
@@ -864,6 +865,7 @@
         revid = self._dostore(oid)
         revid = self._dostore(oid, revid)
         forker.wait_until(
+            "Client has seen all of the transactions from the server",
             lambda :
             perstorage.lastTransaction() == self._storage.lastTransaction()
             )

Modified: ZODB/trunk/src/ZEO/tests/forker.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/forker.py	2009-01-02 21:22:39 UTC (rev 94461)
+++ ZODB/trunk/src/ZEO/tests/forker.py	2009-01-02 21:53:34 UTC (rev 94462)
@@ -330,20 +330,18 @@
     test.globs['wait_disconnected'] = wait_disconnected
 
 
-def wait_until(func, timeout=30, label=None):
-    if not label:
-        label = func.__name__
+def wait_until(label, func, timeout=30):
     now = time.time()
     giveup = now + 30
     while not func():
         now = time.time()
         if time.time() > giveup:
-            raise AssertionError("Timed out waiting for", label)
+            raise AssertionError("Timed out waiting for: ", label)
         time.sleep(0.01)
-        
+
 def wait_connected(storage):
-    wait_until(storage.is_connected)
+    wait_until("storage is connected", storage.is_connected)
 
 def wait_disconnected(storage):
-    def not_connected():
-        return not storage.is_connected()
+    wait_until("storage is disconnected",
+               lambda : not storage.is_connected())

Modified: ZODB/trunk/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/testZEO.py	2009-01-02 21:22:39 UTC (rev 94461)
+++ ZODB/trunk/src/ZEO/tests/testZEO.py	2009-01-02 21:53:34 UTC (rev 94462)
@@ -1139,7 +1139,9 @@
     try to access the object. We'll get a POSKeyError there too:
 
     >>> tid = db.storage.lastTransaction()
-    >>> forker.wait_until(lambda : cs.lastTransaction() == tid)
+    >>> forker.wait_until(
+    ...    'cs has caught up',
+    ...    lambda : cs.lastTransaction() == tid)
     >>> cs.load(oid) # doctest: +ELLIPSIS
     Traceback (most recent call last):
     ...



More information about the Zodb-checkins mailing list