[py-svn] r57247 - in py/branch/event/py/test2: . dsession dsession/testing looponfail looponfail/testing terminal testing

hpk at codespeak.net hpk at codespeak.net
Thu Aug 14 15:42:00 CEST 2008


Author: hpk
Date: Thu Aug 14 15:41:58 2008
New Revision: 57247

Added:
   py/branch/event/py/test2/looponfail/
      - copied from r57235, py/branch/event/py/test2/terminal/
   py/branch/event/py/test2/looponfail/remote.py
      - copied, changed from r57246, py/branch/event/py/test2/terminal/remote.py
   py/branch/event/py/test2/looponfail/testing/
      - copied from r57246, py/branch/event/py/test2/terminal/testing/
   py/branch/event/py/test2/looponfail/testing/test_util.py
      - copied, changed from r57235, py/branch/event/py/test2/dsession/testing/test_looponfailing.py
   py/branch/event/py/test2/looponfail/util.py
      - copied unchanged from r57235, py/branch/event/py/test2/dsession/looponfailing.py
Removed:
   py/branch/event/py/test2/dsession/looponfailing.py
   py/branch/event/py/test2/dsession/testing/test_looponfailing.py
   py/branch/event/py/test2/terminal/
Modified:
   py/branch/event/py/test2/config.py
   py/branch/event/py/test2/dsession/dsession.py
   py/branch/event/py/test2/looponfail/testing/test_remote.py
   py/branch/event/py/test2/testing/test_session.py
Log:
refactor files related to looponfailing into one dir


Modified: py/branch/event/py/test2/config.py
==============================================================================
--- py/branch/event/py/test2/config.py	(original)
+++ py/branch/event/py/test2/config.py	Thu Aug 14 15:41:58 2008
@@ -216,7 +216,7 @@
 # default import paths for sessions 
 
 Session = 'py.__.test2.session'
-LooponfailingSession = 'py.__.test2.terminal.remote'
+LooponfailingSession = 'py.__.test2.looponfail.remote'
 DSession = 'py.__.test2.dsession.dsession'
 
 #

Modified: py/branch/event/py/test2/dsession/dsession.py
==============================================================================
--- py/branch/event/py/test2/dsession/dsession.py	(original)
+++ py/branch/event/py/test2/dsession/dsession.py	Thu Aug 14 15:41:58 2008
@@ -14,7 +14,6 @@
 from py.__.test2.session import Session
 from py.__.test2.runner import OutcomeRepr
 from py.__.test2 import outcome 
-from py.__.test2.dsession import looponfailing 
 
 
 import Queue 
@@ -76,32 +75,6 @@
             raise SystemExit
 
     def main(self, colitems):
-        #if self.config.option.looponfailing:
-        #    self.runsession_looponfailing(colitems)
-        #    exitstatus = 0
-        #else:
-        exitstatus = self.runsession(colitems)
-        return exitstatus
-
-    #def runsession_looponfailing(self, initialcolitems):
-    #    eventrecorder = looponfailing.EventRecorder(self.bus)
-    #    statrecorder = looponfailing.StatRecorder([self.config.topdir])
-    #    colitems = initialcolitems
-    #    while 1:
-    #        self.runsession(colitems[:])
-    #        reports = eventrecorder.getfailures()
-    #        eventrecorder.clear()
-    #        self.bus.notify(event.LooponfailingInfo(reports, [self.config.topdir]))
-    #        if reports:
-    #            colitems = [rep.colitem for rep in reports]
-    #        else:
-    #            if colitems != initialcolitems:
-    #                colitems = initialcolitems
-    #               continue # runagain
-    #        statrecorder.waitonchange(checkinterval=2.0)
-            
-
-    def runsession(self, colitems):
         self.bus.notify(event.TestrunStart())
         self.setup_hosts()
         exitstatus = self.loop(colitems)

Deleted: /py/branch/event/py/test2/dsession/looponfailing.py
==============================================================================
--- /py/branch/event/py/test2/dsession/looponfailing.py	Thu Aug 14 15:41:58 2008
+++ (empty file)
@@ -1,65 +0,0 @@
-import py
-from py.__.test2 import event
-
-class StatRecorder:
-    def __init__(self, rootdirlist):
-        self.rootdirlist = rootdirlist
-        self.statcache = {}
-        self.check() # snapshot state
-
-    def fil(self, p): 
-        return p.ext in ('.py', '.txt', '.c', '.h')
-    def rec(self, p):
-        return p.check(dotfile=0)
-
-    def waitonchange(self, checkinterval=1.0):
-        while 1:
-            changed = self.check()
-            if changed:
-                return
-            py.std.time.sleep(checkinterval)
-
-    def check(self):
-        changed = False
-        statcache = self.statcache
-        newstat = {}
-        for rootdir in self.rootdirlist:
-            for path in rootdir.visit(self.fil, self.rec):
-                oldstat = statcache.get(path, None)
-                if oldstat is not None:
-                    del statcache[path]
-                try:
-                    newstat[path] = curstat = path.stat()
-                except py.error.ENOENT:
-                    if oldstat:
-                        del statcache[path]
-                        changed = True
-                else:
-                    if oldstat:
-                       if oldstat.mtime != curstat.mtime or \
-                          oldstat.size != curstat.size:
-                            changed = True
-                            print "# MODIFIED", path
-                    else:
-                        changed = True
-        if statcache:
-            changed = True
-        self.statcache = newstat
-        return changed
-
-
-class EventRecorder(object):
-    def __init__(self, bus):
-        self.events = []
-        self.bus = bus
-        self.bus.subscribe(self.events.append)
-
-    def getfailures(self):
-        return [ev for ev in self.events 
-                    if isinstance(ev, event.BaseReport) and \
-                       ev.failed]
-    def clear(self):
-        self.events[:] = []
-
-    def unsubscribe(self):
-        self.bus.unsubscribe(self.events.append)

Deleted: /py/branch/event/py/test2/dsession/testing/test_looponfailing.py
==============================================================================
--- /py/branch/event/py/test2/dsession/testing/test_looponfailing.py	Thu Aug 14 15:41:58 2008
+++ (empty file)
@@ -1,73 +0,0 @@
-import py
-from py.__.test2.dsession.looponfailing import StatRecorder, EventRecorder
-from py.__.test2 import event
-
-def test_filechange():
-    tmp = py.test.ensuretemp("test_filechange")
-    hello = tmp.ensure("hello.py")
-    sd = StatRecorder([tmp])
-    changed = sd.check()
-    assert not changed
-
-    hello.write("world")
-    changed = sd.check()
-    assert changed
-
-    tmp.ensure("new.py")
-    changed = sd.check()
-    assert changed
-    
-    tmp.join("new.py").remove()
-    changed = sd.check()
-    assert changed
-
-    tmp.join("a", "b", "c.py").ensure()
-    changed = sd.check()
-    assert changed
-
-    tmp.join("a", "c.txt").ensure()
-    changed = sd.check()
-    assert changed
-    changed = sd.check()
-    assert not changed
-
-    tmp.join("a").remove()
-    changed = sd.check()
-    assert changed
-
-def test_waitonchange():
-    tmp = py.test.ensuretemp("test_waitonchange")
-    sd = StatRecorder([tmp])
-
-    wp = py._thread.WorkerPool(1)
-    reply = wp.dispatch(sd.waitonchange, checkinterval=0.2)
-    py.std.time.sleep(0.05)
-    tmp.ensure("newfile.py")
-    reply.get(timeout=0.5)
-    wp.shutdown()
-    
-def test_eventrecorder():
-    bus = event.EventBus()
-    recorder = EventRecorder(bus)
-    bus.notify(event.NOP())
-    assert recorder.events 
-    assert not recorder.getfailures()
-    rep = event.ItemTestReport(None, failed=True)
-    bus.notify(rep)
-    failures = recorder.getfailures()
-    assert failures == [rep]
-    recorder.clear() 
-    assert not recorder.events
-    assert not recorder.getfailures()
-    recorder.unsubscribe()
-    bus.notify(rep)
-    assert not recorder.events 
-    assert not recorder.getfailures()
-    
-    
-        
-    
-    
-    
-    
-

Copied: py/branch/event/py/test2/looponfail/remote.py (from r57246, py/branch/event/py/test2/terminal/remote.py)
==============================================================================
--- py/branch/event/py/test2/terminal/remote.py	(original)
+++ py/branch/event/py/test2/looponfail/remote.py	Thu Aug 14 15:41:58 2008
@@ -5,13 +5,13 @@
 from py.__.test2.dsession.mypickle import PickleChannel
 from py.__.test2.report.terminal import TerminalReporter
 from py.__.test2 import event
-from py.__.test2.dsession import looponfailing
+from py.__.test2.looponfail import util
 
 class LooponfailingSession(Session):
     def __init__(self, config):
         super(LooponfailingSession, self).__init__(config=config)
         self.rootdirs = [self.config.topdir] # xxx dist_rsync_roots? 
-        self.statrecorder = looponfailing.StatRecorder(self.rootdirs) 
+        self.statrecorder = util.StatRecorder(self.rootdirs) 
         self.remotecontrol = RemoteControl(self.config, notify=self.bus.notify)
 
     def main(self, initialitems):
@@ -82,7 +82,7 @@
             from py.__.test2.dsession.mypickle import PickleChannel
             channel = PickleChannel(channel)
             print "SLAVE: initializing ..."
-            from py.__.test2.terminal.remote import slave_runsession
+            from py.__.test2.looponfail.remote import slave_runsession
             from py.__.test2.dsession import masterslave
             config = masterslave.receive_and_send_pickled_config(channel)
             slave_runsession(channel, config) 

Modified: py/branch/event/py/test2/looponfail/testing/test_remote.py
==============================================================================
--- py/branch/event/py/test2/terminal/testing/test_remote.py	(original)
+++ py/branch/event/py/test2/looponfail/testing/test_remote.py	Thu Aug 14 15:41:58 2008
@@ -1,6 +1,6 @@
 import py
 from py.__.test2.testing import suptest
-from py.__.test2.terminal.remote import LooponfailingSession, LoopState, RemoteControl 
+from py.__.test2.looponfail.remote import LooponfailingSession, LoopState, RemoteControl 
 from py.__.test2 import event
 
 def getevent(l, evtype):

Copied: py/branch/event/py/test2/looponfail/testing/test_util.py (from r57235, py/branch/event/py/test2/dsession/testing/test_looponfailing.py)
==============================================================================
--- py/branch/event/py/test2/dsession/testing/test_looponfailing.py	(original)
+++ py/branch/event/py/test2/looponfail/testing/test_util.py	Thu Aug 14 15:41:58 2008
@@ -1,5 +1,5 @@
 import py
-from py.__.test2.dsession.looponfailing import StatRecorder, EventRecorder
+from py.__.test2.looponfail.util import StatRecorder, EventRecorder
 from py.__.test2 import event
 
 def test_filechange():

Modified: py/branch/event/py/test2/testing/test_session.py
==============================================================================
--- py/branch/event/py/test2/testing/test_session.py	(original)
+++ py/branch/event/py/test2/testing/test_session.py	Thu Aug 14 15:41:58 2008
@@ -223,7 +223,7 @@
         assert failed[1].colitem.name == "test_other"
         assert failed[2].colitem.name == "test_two"
 
-from py.__.test2.terminal.remote import LooponfailingSession
+from py.__.test2.looponfail.remote import LooponfailingSession
 
 class Test_TerminalRemoteSession:
     def test_exec_leads_to_DistSession(self): 



More information about the pytest-commit mailing list