[Checkins] SVN: ZODB/trunk/src/ZEO/tests/forker.py Updated wait_until test helper:

Jim Fulton jim at zope.com
Thu May 13 15:06:44 EDT 2010


Log message for revision 112293:
  Updated wait_until test helper:
  
  - Can use it as a decorator
  
  - Can omit the label, and get the label from the assertion function.
  

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

-=-
Modified: ZODB/trunk/src/ZEO/tests/forker.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/forker.py	2010-05-13 18:36:08 UTC (rev 112292)
+++ ZODB/trunk/src/ZEO/tests/forker.py	2010-05-13 19:06:44 UTC (rev 112293)
@@ -331,11 +331,25 @@
 
     zope.testing.setupstack.register(test, cleanup_servers)
 
+    test.globs['wait_until'] = wait_until
     test.globs['wait_connected'] = wait_connected
     test.globs['wait_disconnected'] = wait_disconnected
 
 
-def wait_until(label, func, timeout=30, onfail=None):
+def wait_until(label=None, func=None, timeout=30, onfail=None):
+    if label is None:
+        if func is not None:
+            label = func.__name__
+    elif not isinstance(label, basestring) and func is None:
+        func = label
+        label = func.__name__
+
+    if func is None:
+        def wait_decorator(f):
+            wait_until(label, f, timeout, onfail)
+
+        return wait_decorator
+
     giveup = time.time() + timeout
     while not func():
         if time.time() > giveup:



More information about the checkins mailing list