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

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <20100513190644.BCC6A9418C__27709.5178761103$1273777615$gmane$org@cvs.zope.org>
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:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.