[py-svn] r33344 - in py/dist/py/test/rsession: . testing

fijal at codespeak.net fijal at codespeak.net
Mon Oct 16 18:24:20 CEST 2006


Author: fijal
Date: Mon Oct 16 18:23:48 2006
New Revision: 33344

Modified:
   py/dist/py/test/rsession/executor.py
   py/dist/py/test/rsession/local.py
   py/dist/py/test/rsession/outcome.py
   py/dist/py/test/rsession/rsession.py
   py/dist/py/test/rsession/testing/test_lsession.py
Log:
Fixed several local version issues of distributed tests. Right now it has the same funcionallity as remote version, altough it might be extended. Probably we want to split reporters as well.


Modified: py/dist/py/test/rsession/executor.py
==============================================================================
--- py/dist/py/test/rsession/executor.py	(original)
+++ py/dist/py/test/rsession/executor.py	Mon Oct 16 18:23:48 2006
@@ -17,9 +17,9 @@
     def execute(self):
         try:
             self.item.run()
-            return Outcome()
+            outcome = Outcome()
         except py.test.Item.Skipped, e: 
-            return Outcome(skipped=str(e))
+            outcome = Outcome(skipped=str(e))
         except:
             excinfo = py.code.ExceptionInfo()
             if isinstance(self.item, py.test.Function): 
@@ -27,7 +27,10 @@
                 code = py.code.Code(fun)
                 excinfo.traceback = excinfo.traceback.cut(
                         path=code.path, firstlineno=code.firstlineno)
-            return Outcome(excinfo=excinfo, setupfailure=False)
+            outcome = Outcome(excinfo=excinfo, setupfailure=False)
+        outcome.stdout = ""
+        outcome.stderr = ""
+        return outcome
 
 class BoxExecutor(RunExecutor):
     """ Same as run executor, but boxes test instead

Modified: py/dist/py/test/rsession/local.py
==============================================================================
--- py/dist/py/test/rsession/local.py	(original)
+++ py/dist/py/test/rsession/local.py	Mon Oct 16 18:23:48 2006
@@ -2,12 +2,13 @@
 """ local-only operations
 """
 
-from py.__.test.rsession.executor import RunExecutor
+from py.__.test.rsession.executor import BoxExecutor
 from py.__.test.rsession import report
+from py.__.test.rsession.outcome import ReprOutcome
 
 def run(item):
-    r = RunExecutor(item)
-    return r.execute()
+    r = BoxExecutor(item)
+    return ReprOutcome(r.execute())
 
 def local_loop(reporter, itemgenerator, shouldstop):
     

Modified: py/dist/py/test/rsession/outcome.py
==============================================================================
--- py/dist/py/test/rsession/outcome.py	(original)
+++ py/dist/py/test/rsession/outcome.py	Mon Oct 16 18:23:48 2006
@@ -16,6 +16,7 @@
         self.setupfailure = setupfailure 
         self.excinfo = excinfo
         self.is_critical = is_critical
+        self.signal = 0
         assert bool(self.passed) + bool(excinfo) + bool(skipped) == 1
     
     def make_excinfo_repr(self):

Modified: py/dist/py/test/rsession/rsession.py
==============================================================================
--- py/dist/py/test/rsession/rsession.py	(original)
+++ py/dist/py/test/rsession/rsession.py	Mon Oct 16 18:23:48 2006
@@ -33,6 +33,7 @@
         self.failed_tests_outcome = []
         self.skipped_tests_outcome = []
         self.out = getout(py.std.sys.stdout)
+        #assert hosts == ['localhost']
         self.failed = dict([(host, 0) for host in hosts])
         self.skipped = dict([(host, 0) for host in hosts])
         self.passed = dict([(host, 0) for host in hosts])
@@ -56,9 +57,13 @@
             print "Unknown report: %s" % what
     
     def report_SendItem(self, item):
+        if item.channel:
+            address = item.channel.gateway.sshaddress
+        else:
+            address = 'localhost'
         if self.config.option.verbose: 
-            print "Sending %s to %s" % (item.item, 
-                                        item.channel.gateway.sshaddress)
+            print "Sending %s to %s" % (item.item,
+                                        address)
 
     def report_HostRSyncing(self, item):
         print "%10s: RSYNC ==> %s" % (item.hostname[:10],
@@ -85,6 +90,8 @@
     
     def hangs(self):
         h = []
+        if not hasattr(self, 'nodes'):
+            return
         for node in self.nodes:
             h += [(i, node.channel.gateway.sshaddress) for i in node.pending]
         if h:
@@ -96,7 +103,10 @@
         if self.failed_tests_outcome:
             self.out.sep("=", " FAILURES ")
         for event in self.failed_tests_outcome:
-            host = event.channel.gateway.sshaddress
+            if event.channel:
+                host = event.channel.gateway.sshaddress
+            else:
+                host = 'localhost'
             self.out.sep('_', "%s on %s" % 
                 (" ".join(event.item.listnames()), host))
             if event.outcome.signal:
@@ -136,7 +146,7 @@
         for index, entry in py.builtin.enumerate(traceback): 
             self.out.sep('-')
             self.out.line("%s: %s" % (entry.path, entry.lineno))
-            self.repr_source(entry.relline, entry.source)
+            self.repr_source(entry.relline, str(entry.source))
         self.out.line("%s: %s" % (excinfo.typename, excinfo.value))
     
     def repr_source(self, relline, source):
@@ -153,8 +163,11 @@
             if isinstance(event, report.ReceivedItemOutcome):
                 outcome = event.outcome
                 text = outcome.skipped
-                itemname = event.channel.gateway.sshaddress + ":" + \
-                    "/".join(colitem.listnames())
+                if event.channel:
+                    itemname = event.channel.gateway.sshaddress + ":" + \
+                        "/".join(colitem.listnames())
+                else:
+                    itemname = "/".join(colitem.listnames())
             elif isinstance(event, report.SkippedTryiter):
                 text = str(event.excinfo.value)
                 itemname = "/".join(colitem.listnames())
@@ -202,7 +215,10 @@
         # XXX: right now we do not do anything with it
     
     def report_ReceivedItemOutcome(self, event):
-        host = event.channel.gateway.sshaddress
+        if event.channel:
+            host = event.channel.gateway.sshaddress
+        else:
+            host = 'localhost'
         if event.outcome.passed:
             status = "PASSED "
             self.passed[host] += 1
@@ -215,7 +231,10 @@
             self.failed[host] += 1
             self.failed_tests_outcome.append(event)
             # we'll take care of them later
-        sshhost = event.channel.gateway.sshaddress
+        if event.channel:
+            sshhost = event.channel.gateway.sshaddress
+        else:
+            sshhost = 'localhost'
         itempath = " ".join(event.item.listnames()[1:])
         print "%10s: %s %s" %(sshhost[:10], status, itempath)
     

Modified: py/dist/py/test/rsession/testing/test_lsession.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_lsession.py	(original)
+++ py/dist/py/test/rsession/testing/test_lsession.py	Mon Oct 16 18:23:48 2006
@@ -36,14 +36,14 @@
         assert len(failevents) == 3
         tb = failevents[0].outcome.excinfo.traceback
         assert str(tb[0].path).find("test_one") != -1
-        assert str(tb[0].getsource()).find("test_2") != -1
-        assert failevents[0].outcome.excinfo.type is AssertionError
+        assert str(tb[0].source).find("test_2") != -1
+        assert failevents[0].outcome.excinfo.typename == 'AssertionError'
         tb = failevents[1].outcome.excinfo.traceback
         assert str(tb[0].path).find("test_one") != -1
-        assert str(tb[0].getsource()).find("test_3") != -1
-        assert failevents[1].outcome.excinfo.type is ValueError
+        assert str(tb[0].source).find("test_3") != -1
+        assert failevents[1].outcome.excinfo.typename == 'ValueError'
         assert str(failevents[1].outcome.excinfo.value) == '23'
         tb = failevents[2].outcome.excinfo.traceback
-        assert failevents[2].outcome.excinfo.type is TypeError
+        assert failevents[2].outcome.excinfo.typename == 'TypeError'
         assert str(tb[0].path).find("executor") != -1
-        assert str(tb[0].getsource()).find("execute") != -1
+        assert str(tb[0].source).find("execute") != -1


More information about the py-svn mailing list