[py-svn] r57251 - in py/branch/event/py/test2: looponfail looponfail/testing testing

hpk at codespeak.net hpk at codespeak.net
Thu Aug 14 16:58:43 CEST 2008


Author: hpk
Date: Thu Aug 14 16:58:43 2008
New Revision: 57251

Modified:
   py/branch/event/py/test2/looponfail/testing/test_remote.py
   py/branch/event/py/test2/looponfail/testing/test_util.py
   py/branch/event/py/test2/looponfail/util.py
   py/branch/event/py/test2/testing/acceptance_test.py
Log:
* remove pycfiles by default for changed .py files
* enable acceptance test for looponfailing 



Modified: py/branch/event/py/test2/looponfail/testing/test_remote.py
==============================================================================
--- py/branch/event/py/test2/looponfail/testing/test_remote.py	(original)
+++ py/branch/event/py/test2/looponfail/testing/test_remote.py	Thu Aug 14 16:58:43 2008
@@ -69,8 +69,6 @@
             def test_two():
                 assert 1
         """))
-        pyc = modcol.fspath + "c"
-        if pyc.check(): pyc.remove() # XXX move to statrecorder?
         assert session.statrecorder.check()
         events[:] = []
         session.loop_once(loopstate)

Modified: py/branch/event/py/test2/looponfail/testing/test_util.py
==============================================================================
--- py/branch/event/py/test2/looponfail/testing/test_util.py	(original)
+++ py/branch/event/py/test2/looponfail/testing/test_util.py	Thu Aug 14 16:58:43 2008
@@ -35,6 +35,23 @@
     changed = sd.check()
     assert changed
 
+def test_pycremoval():
+    tmp = py.test.ensuretemp("test_pycremoval")
+    hello = tmp.ensure("hello.py")
+    sd = StatRecorder([tmp])
+    changed = sd.check()
+    assert not changed
+
+    pycfile = hello + "c"
+    pycfile.ensure()
+    changed = sd.check()
+    assert not changed 
+
+    hello.write("world")
+    changed = sd.check()
+    assert not pycfile.check()
+    
+
 def test_waitonchange():
     tmp = py.test.ensuretemp("test_waitonchange")
     sd = StatRecorder([tmp])

Modified: py/branch/event/py/test2/looponfail/util.py
==============================================================================
--- py/branch/event/py/test2/looponfail/util.py	(original)
+++ py/branch/event/py/test2/looponfail/util.py	Thu Aug 14 16:58:43 2008
@@ -19,7 +19,7 @@
                 return
             py.std.time.sleep(checkinterval)
 
-    def check(self):
+    def check(self, removepycfiles=True):
         changed = False
         statcache = self.statcache
         newstat = {}
@@ -40,6 +40,11 @@
                           oldstat.size != curstat.size:
                             changed = True
                             print "# MODIFIED", path
+                            if removepycfiles and path.ext == ".py":
+                                pycfile = path + "c"
+                                if pycfile.check():
+                                    pycfile.remove()
+                                
                     else:
                         changed = True
         if statcache:

Modified: py/branch/event/py/test2/testing/acceptance_test.py
==============================================================================
--- py/branch/event/py/test2/testing/acceptance_test.py	(original)
+++ py/branch/event/py/test2/testing/acceptance_test.py	Thu Aug 14 16:58:43 2008
@@ -379,22 +379,18 @@
             def test_1():
                 assert 1 == 0 
         """)
-       
+        test_one.setmtime(test_one.mtime() - 5.0)  
         child = spawn("%s %s --looponfailing test_one.py" % (py.std.sys.executable, 
                       str(pytestpath)))
         child.timeout = EXPECTTIMEOUT
         child.expect("assert 1 == 0")
         child.expect("test_one.py:")
         child.expect("failures: 1")
-
         child.expect("waiting for changes")
-        
         test_one.write(py.code.Source("""
             def test_1():
                 assert 1 == 1
         """))
-        pyc = test_one + "c"
-        if pyc.check(): pyc.remove() # XXX 
         child.expect("MODIFIED.*test_one.py", timeout=4.0)
         child.expect("failures: no failures", timeout=5.0)
         child.kill(15)



More information about the pytest-commit mailing list