[Checkins] SVN: zc.zk/trunk/src/zc/zk/test Moved wait_until to testing

Jim Fulton jim at zope.com
Tue Dec 6 19:25:48 UTC 2011


Log message for revision 123599:
  Moved wait_until to testing

Changed:
  U   zc.zk/trunk/src/zc/zk/testing.py
  U   zc.zk/trunk/src/zc/zk/tests.py

-=-
Modified: zc.zk/trunk/src/zc/zk/testing.py
===================================================================
--- zc.zk/trunk/src/zc/zk/testing.py	2011-12-06 17:12:34 UTC (rev 123598)
+++ zc.zk/trunk/src/zc/zk/testing.py	2011-12-06 19:25:47 UTC (rev 123599)
@@ -33,6 +33,19 @@
     if not cond:
         print 'assertion failed: ', mess
 
+def wait_until(func=None, timeout=9):
+    """Wait until a function returns true.
+
+    Raise an AssertionError on timeout.
+    """
+    if func():
+        return
+    deadline = time.time()+timeout
+    while not func():
+        time.sleep(.01)
+        if time.time() > deadline:
+            raise AssertionError('timeout')
+
 def setUp(test, tree=None, connection_string='zookeeper.example.com:2181'):
     """Set up zookeeper emulation.
 

Modified: zc.zk/trunk/src/zc/zk/tests.py
===================================================================
--- zc.zk/trunk/src/zc/zk/tests.py	2011-12-06 17:12:34 UTC (rev 123598)
+++ zc.zk/trunk/src/zc/zk/tests.py	2011-12-06 19:25:47 UTC (rev 123599)
@@ -32,15 +32,6 @@
 import zope.testing.renormalizing
 import unittest
 
-def wait_until(func, timeout=9):
-    if func():
-        return
-    deadline = time.time()+timeout
-    while not func():
-        time.sleep(.01)
-        if time.time() > deadline:
-            raise AssertionError('timeout')
-
 class LoggingTests(unittest.TestCase):
 
     def test_logging(self):
@@ -54,7 +45,7 @@
             zookeeper.close(handle)
         except:
             pass
-        wait_until(lambda : 'environment' in f.getvalue())
+        zc.zk.testing.wait_until(lambda : 'environment' in f.getvalue())
         logger.setLevel(logging.NOTSET)
         logger.removeHandler(h)
 
@@ -85,7 +76,7 @@
             zk = zc.zk.ZooKeeper()
             return zk
 
-        wait_until(lambda : init.call_args)
+        zc.zk.testing.wait_until(lambda : init.call_args)
         (zkaddr, self.__session_watcher), kw = init.call_args
         self.assertEqual((zkaddr, kw), ('127.0.0.1:2181', {}))
         self.__session_watcher(



More information about the checkins mailing list