[pypy-svn] r34571 - pypy/dist/pypy/module/thread/test

pedronis at codespeak.net pedronis at codespeak.net
Mon Nov 13 16:51:28 CET 2006


Author: pedronis
Date: Mon Nov 13 16:51:27 2006
New Revision: 34571

Modified:
   pypy/dist/pypy/module/thread/test/support.py
Log:
make module/thread tests work with pypy-c py.test -A too.



Modified: pypy/dist/pypy/module/thread/test/support.py
==============================================================================
--- pypy/dist/pypy/module/thread/test/support.py	(original)
+++ pypy/dist/pypy/module/thread/test/support.py	Mon Nov 13 16:51:27 2006
@@ -1,6 +1,6 @@
 import py
 import time, gc
-from pypy.conftest import gettestobjspace
+from pypy.conftest import gettestobjspace, option
 from pypy.interpreter.gateway import ObjSpace, W_Root, interp2app_temp
 
 
@@ -24,7 +24,21 @@
         space = gettestobjspace(usemodules=('thread', 'time'))
         cls.space = space
 
-        cls.w_waitfor = space.wrap(interp2app_temp(waitfor))
+        if option.runappdirect:
+            def plain_waitfor(condition, timeout=300.0):
+                adaptivedelay = 0.04
+                limit = time.time() + timeout
+                while time.time() <= limit:
+                    time.sleep(adaptivedelay)
+                    gc.collect()
+                    if condition():
+                        return
+                    adaptivedelay *= 1.05
+                print '*** timed out ***'
+                
+            cls.w_waitfor = plain_waitfor
+        else:
+            cls.w_waitfor = space.wrap(interp2app_temp(waitfor))
         cls.w_busywait = space.appexec([], """():
             import time
             return time.sleep



More information about the Pypy-commit mailing list