[py-svn] r31490 - in py/branch/distributed/py/test/rsession: . testing

hpk at codespeak.net hpk at codespeak.net
Tue Aug 22 17:44:35 CEST 2006


Author: hpk
Date: Tue Aug 22 17:44:29 2006
New Revision: 31490

Added:
   py/branch/distributed/py/test/rsession/master.py
      - copied unchanged from r31489, py/branch/distributed/py/test/rsession/masternode.py
   py/branch/distributed/py/test/rsession/slave.py
      - copied unchanged from r31489, py/branch/distributed/py/test/rsession/slavenode.py
   py/branch/distributed/py/test/rsession/testing/test_master.py
      - copied, changed from r31488, py/branch/distributed/py/test/rsession/testing/test_masternode.py
   py/branch/distributed/py/test/rsession/testing/test_slave.py
      - copied, changed from r31489, py/branch/distributed/py/test/rsession/testing/test_slavenode.py
Removed:
   py/branch/distributed/py/test/rsession/masternode.py
   py/branch/distributed/py/test/rsession/slavenode.py
   py/branch/distributed/py/test/rsession/testing/test_masternode.py
   py/branch/distributed/py/test/rsession/testing/test_slavenode.py
Log:
(fijal, hpk) refactor towards nice slave and master naming. 


Deleted: /py/branch/distributed/py/test/rsession/masternode.py
==============================================================================
--- /py/branch/distributed/py/test/rsession/masternode.py	Tue Aug 22 17:44:29 2006
+++ (empty file)
@@ -1,30 +0,0 @@
-"""
-Node code for Master. 
-"""
-from py.__.test.rsession.outcome import ReprOutcome 
-
-class MasterNode(object):
-    def __init__(self, channel, report):
-        self.channel = channel
-        self.report = report
-        channel.setcallback(self.receive_result)
-        self.pending = []
-
-    def receive_result(self, outcomestring):
-        repr_outcome = ReprOutcome(outcomestring)
-        item = self.pending.pop()
-        self.report((item, repr_outcome))
-
-    def send(self, item):
-        self.pending.insert(0, item)
-        itemspec = "/".join(item.listnames())
-        self.channel.send(itemspec)
-
-# master side: 
-# gw = SshGateway(sshhost)
-# rsync -az --delete --exclude=.svn %(source)s %(sshhost)s:%(path)s
-# c = gw.remote_exec(slave_main) 
-# c.send(path)
-#
-
-

Deleted: /py/branch/distributed/py/test/rsession/slavenode.py
==============================================================================
--- /py/branch/distributed/py/test/rsession/slavenode.py	Tue Aug 22 17:44:29 2006
+++ (empty file)
@@ -1,40 +0,0 @@
-"""
-Node code for slaves. 
-"""
-
-import py
-from py.__.test.rsession.executor import Executor 
-
-class SlaveNode(object):
-    def __init__(self, rootcollector):
-        self.rootcollector = rootcollector
-
-    def getitem(self, namelist):
-        if isinstance(namelist, str):
-            namelist = namelist.split("/")
-        cur = self.rootcollector
-        for name in namelist:
-            next = cur.join(name)
-            assert next is not None, (cur, name)
-            cur = next
-        return cur
-
-    def execute(self, itemspec): 
-        item = self.getitem(itemspec)
-        ex = Executor(item.obj, setup=item.setup)
-        return ex.execute()
-
-    def run(self, itemspec):
-        outcome = self.execute(itemspec)
-        return outcome.make_repr()
-
-def slave_main(receive, send): 
-    path = receive()
-    rootcol = py.test.collect.Directory(path)
-    node = SlaveNode(rootcol)
-    while 1:
-        nextitem = receive()
-        if nextitem is None:
-            break
-        res = node.run(nextitem) 
-        send(res)

Copied: py/branch/distributed/py/test/rsession/testing/test_master.py (from r31488, py/branch/distributed/py/test/rsession/testing/test_masternode.py)
==============================================================================
--- py/branch/distributed/py/test/rsession/testing/test_masternode.py	(original)
+++ py/branch/distributed/py/test/rsession/testing/test_master.py	Tue Aug 22 17:44:29 2006
@@ -1,7 +1,7 @@
 """ test master node """
 
 import py
-from py.__.test.rsession.masternode import MasterNode
+from py.__.test.rsession.master import MasterNode
 from py.__.test.rsession.outcome import Outcome 
 
 class DummyChannel(object):

Deleted: /py/branch/distributed/py/test/rsession/testing/test_masternode.py
==============================================================================
--- /py/branch/distributed/py/test/rsession/testing/test_masternode.py	Tue Aug 22 17:44:29 2006
+++ (empty file)
@@ -1,28 +0,0 @@
-""" test master node """
-
-import py
-from py.__.test.rsession.masternode import MasterNode
-from py.__.test.rsession.outcome import Outcome 
-
-class DummyChannel(object):
-    def __init__(self):
-        self.sent = []
-
-    def setcallback(self, func):
-        self.callback = func 
-
-    def send(self, item):
-        assert py.std.marshal.dumps(item)
-        self.sent.append(item)
-
-def test_masternode():
-    ch = DummyChannel()
-    reportlist = []
-    mnode = MasterNode(ch, reportlist.append)
-    mnode.send(py.test.Item("ok"))
-    mnode.send(py.test.Item("notok"))
-    ch.callback(Outcome().make_repr())
-    ch.callback(Outcome(excinfo=42).make_repr())
-    assert len(reportlist) == 2
-    assert reportlist[0][1].passed 
-    assert not reportlist[1][1].passed 

Copied: py/branch/distributed/py/test/rsession/testing/test_slave.py (from r31489, py/branch/distributed/py/test/rsession/testing/test_slavenode.py)
==============================================================================
--- py/branch/distributed/py/test/rsession/testing/test_slavenode.py	(original)
+++ py/branch/distributed/py/test/rsession/testing/test_slave.py	Tue Aug 22 17:44:29 2006
@@ -1,6 +1,6 @@
 
 """ Testing the slave side node code (in a local way). """
-from py.__.test.rsession.slavenode import SlaveNode, slave_main
+from py.__.test.rsession.slave import SlaveNode, slave_main
 from py.__.test.rsession.outcome import ReprOutcome
 import py
 
@@ -18,18 +18,18 @@
     node = SlaveNode(rootcol) 
     return node
 
-def test_slavenode_getitem():
+def test_slave_getitem():
     node = gettestnode()
-    item = node.getitem("py/test/rsession/testing/test_slavenode.py/funcpass")
+    item = node.getitem("py/test/rsession/testing/test_slave.py/funcpass")
     assert isinstance(item, py.test.Item) 
     assert item.name == 'funcpass' 
     res = item.run()
     assert res is None 
 
-def test_slavenode_run_passing():
+def test_slave_run_passing():
     node = gettestnode()
     outcome = node.execute("py/test/rsession/testing/"
-                           "test_slavenode.py/funcpass")
+                           "test_slave.py/funcpass")
     assert outcome.passed 
     assert not outcome.setupfailure 
 
@@ -38,10 +38,10 @@
     assert reproutcome.passed 
     assert not reproutcome.setupfailure 
 
-def test_slavenode_run_failing():
+def test_slave_run_failing():
     node = gettestnode()
     outcome = node.execute("py/test/rsession/testing/"
-                           "test_slavenode.py/funcfail")
+                           "test_slave.py/funcfail")
     assert not outcome.passed 
     assert not outcome.setupfailure 
     assert len(outcome.excinfo.traceback) == 1
@@ -53,10 +53,10 @@
     assert not reproutcome.setupfailure 
     assert reproutcome.excinfo
 
-def test_slavenode_run_failing_wrapped():
+def test_slave_run_failing_wrapped():
     node = gettestnode()
     repr_outcome = node.run("py/test/rsession/testing/"
-                       "test_slavenode.py/funcfail")
+                       "test_slave.py/funcfail")
     outcome = ReprOutcome(repr_outcome)  
     assert not outcome.passed 
     assert not outcome.setupfailure 
@@ -65,8 +65,8 @@
 def test_slave_main_simple(): 
     res = []
     q = [None, 
-         "py/test/rsession/testing/test_slavenode.py/funcpass",
-         "py/test/rsession/testing/test_slavenode.py/funcfail",
+         "py/test/rsession/testing/test_slave.py/funcpass",
+         "py/test/rsession/testing/test_slave.py/funcfail",
          str(rootdir)]
     slave_main(q.pop, res.append)
     assert len(res) == 2

Deleted: /py/branch/distributed/py/test/rsession/testing/test_slavenode.py
==============================================================================
--- /py/branch/distributed/py/test/rsession/testing/test_slavenode.py	Tue Aug 22 17:44:29 2006
+++ (empty file)
@@ -1,77 +0,0 @@
-
-""" Testing the slave side node code (in a local way). """
-from py.__.test.rsession.slavenode import SlaveNode, slave_main
-from py.__.test.rsession.outcome import ReprOutcome
-import py
-
-def setup_module(mod):
-    mod.rootdir = py.path.local(py.__file__).dirpath().dirpath()
-
-def funcpass(): 
-    pass
-
-def funcfail():
-    raise AssertionError("hello world")
-
-def gettestnode():
-    rootcol = py.test.collect.Directory(rootdir)
-    node = SlaveNode(rootcol) 
-    return node
-
-def test_slavenode_getitem():
-    node = gettestnode()
-    item = node.getitem("py/test/rsession/testing/test_slavenode.py/funcpass")
-    assert isinstance(item, py.test.Item) 
-    assert item.name == 'funcpass' 
-    res = item.run()
-    assert res is None 
-
-def test_slavenode_run_passing():
-    node = gettestnode()
-    outcome = node.execute("py/test/rsession/testing/"
-                           "test_slavenode.py/funcpass")
-    assert outcome.passed 
-    assert not outcome.setupfailure 
-
-    ser = outcome.make_repr()
-    reproutcome = ReprOutcome(ser) 
-    assert reproutcome.passed 
-    assert not reproutcome.setupfailure 
-
-def test_slavenode_run_failing():
-    node = gettestnode()
-    outcome = node.execute("py/test/rsession/testing/"
-                           "test_slavenode.py/funcfail")
-    assert not outcome.passed 
-    assert not outcome.setupfailure 
-    assert len(outcome.excinfo.traceback) == 1
-    assert outcome.excinfo.traceback[-1].frame.code.name == 'funcfail'
-
-    ser = outcome.make_repr()
-    reproutcome = ReprOutcome(ser) 
-    assert not reproutcome.passed 
-    assert not reproutcome.setupfailure 
-    assert reproutcome.excinfo
-
-def test_slavenode_run_failing_wrapped():
-    node = gettestnode()
-    repr_outcome = node.run("py/test/rsession/testing/"
-                       "test_slavenode.py/funcfail")
-    outcome = ReprOutcome(repr_outcome)  
-    assert not outcome.passed 
-    assert not outcome.setupfailure 
-    assert outcome.excinfo
-
-def test_slave_main_simple(): 
-    res = []
-    q = [None, 
-         "py/test/rsession/testing/test_slavenode.py/funcpass",
-         "py/test/rsession/testing/test_slavenode.py/funcfail",
-         str(rootdir)]
-    slave_main(q.pop, res.append)
-    assert len(res) == 2
-    res_repr = [ReprOutcome(r) for r in res]
-    assert not res_repr[0].passed
-    assert res_repr[1].passed
-
-



More information about the pytest-commit mailing list