[py-svn] r56814 - in py/branch/event/py/test2: . rep rep/testing testing

hpk at codespeak.net hpk at codespeak.net
Mon Jul 28 16:02:04 CEST 2008


Author: hpk
Date: Mon Jul 28 16:02:03 2008
New Revision: 56814

Added:
   py/branch/event/py/test2/rep/testing/test_collectonly.py
      - copied, changed from r56813, py/branch/event/py/test2/rep/testing/test_terminal.py
Modified:
   py/branch/event/py/test2/genitem.py
   py/branch/event/py/test2/rep/collectonly.py
   py/branch/event/py/test2/rep/reporter.py
   py/branch/event/py/test2/rep/rest.py
   py/branch/event/py/test2/rep/terminal.py
   py/branch/event/py/test2/rep/testing/test_rest.py
   py/branch/event/py/test2/rep/testing/test_terminal.py
   py/branch/event/py/test2/rep/web.py
   py/branch/event/py/test2/rep/webjs.py
   py/branch/event/py/test2/repevent.py
   py/branch/event/py/test2/testing/test_session.py
Log:
* rename event DeselectedTest -> DeselectedItem 
* add DeselectedItem support to collectonly
* remove some unneeded events



Modified: py/branch/event/py/test2/genitem.py
==============================================================================
--- py/branch/event/py/test2/genitem.py	(original)
+++ py/branch/event/py/test2/genitem.py	Mon Jul 28 16:02:03 2008
@@ -10,7 +10,7 @@
         bus = next._config.bus
         if isinstance(next, Item):
             if next._skipbykeyword(keywordexpr):
-                bus.notify(repevent.DeselectedTest(next, keywordexpr))
+                bus.notify(repevent.DeselectedItem(next, keywordexpr))
                 if next._config.option.keyword_oneshot:
                     keywordexpr = None
             else:

Modified: py/branch/event/py/test2/rep/collectonly.py
==============================================================================
--- py/branch/event/py/test2/rep/collectonly.py	(original)
+++ py/branch/event/py/test2/rep/collectonly.py	Mon Jul 28 16:02:03 2008
@@ -24,7 +24,7 @@
     def report_CollectionFailed(self, event):
         self.out.line(" " * self.indent + "- FAILED TO LOAD MODULE -")
 
-    def report_DeselectedTest(self, event):
+    def report_DeselectedItem(self, event):
         self.out.line(" " * self.indent + "- skipped -")
 
     def summary(self):

Modified: py/branch/event/py/test2/rep/reporter.py
==============================================================================
--- py/branch/event/py/test2/rep/reporter.py	(original)
+++ py/branch/event/py/test2/rep/reporter.py	Mon Jul 28 16:02:03 2008
@@ -239,7 +239,7 @@
                 outcome = event.outcome
                 text = outcome.skipped.value
                 itemname = repr(outcome.skipped.traceback[-2]).split("\n")[0]
-            elif isinstance(event, repevent.DeselectedTest):
+            elif isinstance(event, repevent.DeselectedItem):
                 text = str(event.excinfo.value)
                 itemname = "/".join(colitem.listnames())
             if text not in texts:
@@ -285,7 +285,7 @@
             (total, skipped_str, failed_str, self.timeend - self.timestart,
              self.timersync - self.timestart))
     
-    def report_DeselectedTest(self, event):
+    def report_DeselectedItem(self, event):
         #event.outcome.excinfo.source = 
         self.skipped_tests_outcome.append(event)
     
@@ -345,7 +345,7 @@
         # argh! bad hack, need to fix it
         self.failed[self.hosts[0]] += 1
     
-    def report_DeselectedTest(self, event):
+    def report_DeselectedItem(self, event):
         self.out.line("Skipped (%s) %s\n" % (str(event.excinfo.value), "/".
             join(event.item.listnames())))
 
@@ -384,7 +384,7 @@
         self.out.sep("=", " %d test run%s%s in %.2fs" % 
             (total, skipped_str, failed_str, self.timeend - self.timestart))
 
-    def report_DeselectedTest(self, event):
+    def report_DeselectedItem(self, event):
         #self.show_item(event.item, False)
         if isinstance(event.item, py.test2.collect.Module):
             self.out.write("- skipped (%s)" % event.excinfo.value)

Modified: py/branch/event/py/test2/rep/rest.py
==============================================================================
--- py/branch/event/py/test2/rep/rest.py	(original)
+++ py/branch/event/py/test2/rep/rest.py	Mon Jul 28 16:02:03 2008
@@ -132,7 +132,7 @@
                 outcome = event.outcome
                 text = outcome.skipped
                 itemname = self.get_item_name(event, colitem)
-            elif isinstance(event, repevent.DeselectedTest):
+            elif isinstance(event, repevent.DeselectedItem):
                 text = str(event.excinfo.value)
                 itemname = "/".join(colitem.listnames())
             if text not in texts:

Modified: py/branch/event/py/test2/rep/terminal.py
==============================================================================
--- py/branch/event/py/test2/rep/terminal.py	(original)
+++ py/branch/event/py/test2/rep/terminal.py	Mon Jul 28 16:02:03 2008
@@ -64,16 +64,12 @@
     def rep_ItemStart(self, event):
         self.out.line(self.indent + str(event.item))
 
+    def rep_DeselectedItem(self, event):
+        msg = "DESELECTED: "
+        self.out.line(self.indent + msg + str(event.item))
+
     def rep_CollectionFinish(self, ev):
         excinfo = ev.excinfo
         if excinfo is not None:
             self.out.line(self.indent + "!!! %s !!!" % excinfo.exconly())
         self.indent = self.indent[:-len(self.INDENT)]
-
-    #def rep_DeselectedTest(self, event):
-    #    self.out.line(" " * self.indent + "- skipped -")
-
-    #def summary(self):
-    #    self.out.sep("=", "Total time: %.1f" % (self.timeend - self.timestart))
-        
-        

Copied: py/branch/event/py/test2/rep/testing/test_collectonly.py (from r56813, py/branch/event/py/test2/rep/testing/test_terminal.py)
==============================================================================
--- py/branch/event/py/test2/rep/testing/test_terminal.py	(original)
+++ py/branch/event/py/test2/rep/testing/test_collectonly.py	Mon Jul 28 16:02:03 2008
@@ -7,6 +7,11 @@
 def setup_module(mod):
     mod.tmpdir = py.test.ensuretemp(mod.__name__)
 
+def popvalue(stringio):
+    value = stringio.getvalue().rstrip()
+    stringio.truncate(0)
+    return value
+
 class InlineCollect:
     def setup_class(cls):
         cls.clstmpdir = tmpdir.join(cls.__name__)
@@ -21,19 +26,8 @@
         config = py.test2.config._reparse([path] + configargs)
         return config._getcollector(path)
 
-class TestTerminal:
-    def test_session_reporter_subscription(self):
-        config = py.test2.config._reparse(['xxx'])
-        session = config.initsession()
-        session.sessionstarts()
-        rep = session.reporter
-        assert isinstance(rep, TerminalReporter)
-        assert rep.processevent in config.bus._subscribers
-        session.sessionfinishes()
-        assert rep.processevent not in config.bus._subscribers
-
 class TestCollectonly(InlineCollect):
-    def test_collectonly(self):
+    def test_collectonly_basic(self):
         modcol = self.getmodulecol(['--collectonly'], """
             def test_func():
                 pass
@@ -43,13 +37,16 @@
         indent = rep.indent
         rep.processevent(repevent.CollectionStart(modcol))
         s = popvalue(stringio)
-        assert s == "<Module 'test_collectonly.py'>"
+        assert s == "<Module 'test_collectonly_basic.py'>"
 
         item = modcol.join("test_func")
         rep.processevent(repevent.ItemStart(item))
         s = popvalue(stringio)
         assert s == "  <Function 'test_func'>"
-             
+        rep.processevent(repevent.DeselectedItem(item, None))
+        s = popvalue(stringio)
+        assert s == "  DESELECTED: <Function 'test_func'>"
+
         rep.processevent(repevent.CollectionFinish(modcol))
         assert rep.indent == indent 
 
@@ -90,7 +87,3 @@
               !!! ValueError: 0 !!!
         """)
 
-def popvalue(stringio):
-    value = stringio.getvalue().rstrip()
-    stringio.truncate(0)
-    return value

Modified: py/branch/event/py/test2/rep/testing/test_rest.py
==============================================================================
--- py/branch/event/py/test2/rep/testing/test_rest.py	(original)
+++ py/branch/event/py/test2/rep/testing/test_rest.py	Mon Jul 28 16:02:03 2008
@@ -178,7 +178,7 @@
         class FakeOutcome(Container, repevent.ItemFinish):
             pass
 
-        class FakeTryiter(Container, repevent.DeselectedTest):
+        class FakeTryiter(Container, repevent.DeselectedItem):
             pass
         
         reporter.skips()

Modified: py/branch/event/py/test2/rep/testing/test_terminal.py
==============================================================================
--- py/branch/event/py/test2/rep/testing/test_terminal.py	(original)
+++ py/branch/event/py/test2/rep/testing/test_terminal.py	Mon Jul 28 16:02:03 2008
@@ -4,23 +4,6 @@
 from py.__.test2.testing import suptest
 from py.__.test2.genitem import genitems
 
-def setup_module(mod):
-    mod.tmpdir = py.test.ensuretemp(mod.__name__)
-
-class InlineCollect:
-    def setup_class(cls):
-        cls.clstmpdir = tmpdir.join(cls.__name__)
-        
-    def setup_method(self, method):
-        self.tmpdir = self.clstmpdir.join(method.__name__)
-
-    def getmodulecol(self, configargs, source):
-        self.tmpdir.ensure("__init__.py")
-        path = self.tmpdir.ensure(self.tmpdir.purebasename + ".py")
-        path.write(py.code.Source(source))
-        config = py.test2.config._reparse([path] + configargs)
-        return config._getcollector(path)
-
 class TestTerminal:
     def test_session_reporter_subscription(self):
         config = py.test2.config._reparse(['xxx'])
@@ -32,65 +15,3 @@
         session.sessionfinishes()
         assert rep.processevent not in config.bus._subscribers
 
-class TestCollectonly(InlineCollect):
-    def test_collectonly(self):
-        modcol = self.getmodulecol(['--collectonly'], """
-            def test_func():
-                pass
-        """)
-        stringio = py.std.cStringIO.StringIO()
-        rep = CollectonlyReporter(modcol._config, out=stringio)
-        indent = rep.indent
-        rep.processevent(repevent.CollectionStart(modcol))
-        s = popvalue(stringio)
-        assert s == "<Module 'test_collectonly.py'>"
-
-        item = modcol.join("test_func")
-        rep.processevent(repevent.ItemStart(item))
-        s = popvalue(stringio)
-        assert s == "  <Function 'test_func'>"
-             
-        rep.processevent(repevent.CollectionFinish(modcol))
-        assert rep.indent == indent 
-
-    def test_collectonly_skipped_module(self):
-        modcol = self.getmodulecol(['--collectonly'], """
-            import py
-            py.test2.skip("nomod")
-        """)
-        stringio = py.std.cStringIO.StringIO()
-        rep = CollectonlyReporter(modcol._config, out=stringio)
-        rep.activate(modcol._config.bus)
-        cols = list(genitems([modcol]))
-        assert len(cols) == 0
-        stringio.seek(0)
-        lines = stringio.readlines()
-        lines = map(str.rstrip, lines)
-        print lines
-        suptest.assert_lines_contain_lines(lines, """
-            <Module 'test_collectonly_skipped_module.py'>
-              !!! Skipped: 'nomod' !!!
-        """)
-
-    def test_collectonly_failed_module(self):
-        modcol = self.getmodulecol(['--collectonly'], """
-            raise ValueError(0)
-        """)
-        stringio = py.std.cStringIO.StringIO()
-        rep = CollectonlyReporter(modcol._config, out=stringio)
-        rep.activate(modcol._config.bus)
-        cols = list(genitems([modcol]))
-        assert len(cols) == 0
-        stringio.seek(0)
-        lines = stringio.readlines()
-        lines = map(str.rstrip, lines)
-        print lines
-        suptest.assert_lines_contain_lines(lines, """
-            <Module 'test_collectonly_failed_module.py'>
-              !!! ValueError: 0 !!!
-        """)
-
-def popvalue(stringio):
-    value = stringio.getvalue().rstrip()
-    stringio.truncate(0)
-    return value

Modified: py/branch/event/py/test2/rep/web.py
==============================================================================
--- py/branch/event/py/test2/rep/web.py	(original)
+++ py/branch/event/py/test2/rep/web.py	Mon Jul 28 16:02:03 2008
@@ -250,7 +250,7 @@
             args = {'hostname' : event.host.hostname, 'hostkey' : event.host.hostid}
         elif isinstance(event, repevent.FailedTryiter):
             args = add_item(event)
-        elif isinstance(event, repevent.DeselectedTest):
+        elif isinstance(event, repevent.DeselectedItem):
             args = add_item(event)
             args['reason'] = str(event.excinfo.value)
         else:

Modified: py/branch/event/py/test2/rep/webjs.py
==============================================================================
--- py/branch/event/py/test2/rep/webjs.py	(original)
+++ py/branch/event/py/test2/rep/webjs.py	Mon Jul 28 16:02:03 2008
@@ -222,7 +222,7 @@
         module_part.appendChild(tr)
         item_name = msg['fullitemname']
         exported_methods.show_fail(item_name, fail_come_back)
-    elif msg['type'] == 'DeselectedTest':
+    elif msg['type'] == 'DeselectedItem':
         module_part = get_elem(msg['fullitemname'])
         if not module_part:
             glob.pending.append(msg)

Modified: py/branch/event/py/test2/repevent.py
==============================================================================
--- py/branch/event/py/test2/repevent.py	(original)
+++ py/branch/event/py/test2/repevent.py	Mon Jul 28 16:02:03 2008
@@ -1,13 +1,12 @@
-""" Reporter classes for showing asynchronous and synchronous status events
+""" 
+    test collection and execution events 
 """
 
 import py
 import time
 from py.__.test2.outcome import Skipped
-# XXX the below line helps to deal with the py/test py/test2 situation
 from py.__.test.outcome import Skipped as Skipped2
 
-
 class BaseEvent(object):
     def __repr__(self):
         l = ["%s=%s" %(key, value)
@@ -31,6 +30,10 @@
         self.session = session 
         self.timeend = time.time()
 
+# ----------------------------------------------------------------------
+# Events related to collecting Collectors 
+# ----------------------------------------------------------------------
+
 class CollectionStart(BaseEvent):
     def __init__(self, collector):
         self.collector = collector 
@@ -40,19 +43,20 @@
         self.collector = collector 
         self.excinfo = excinfo 
 
-class DeselectedTest(BaseEvent):
-    def __init__(self, item, keywordexpr): 
-        self.item = item
-        self.keywordexpr = keywordexpr
+# ----------------------------------------------------------------------
+# Events related to collecting and executing test Items 
+# ----------------------------------------------------------------------
 
 class ItemStart(BaseEvent):
     def __init__(self, item):
         self.item = item
         self.time = timestamp()
 
-# ----------------------------------------------------------------------
-# Report of the run of a single test (might come from a disttributed run) 
-# ----------------------------------------------------------------------
+class DeselectedItem(BaseEvent):
+    def __init__(self, item, keywordexpr): 
+        self.item = item
+        self.keywordexpr = keywordexpr
+
 
 import marshal
 
@@ -126,19 +130,3 @@
         self.host = host
         self.root = root
 
-# ----------------------------------------------------------------------
-# XXX Extra Events XXX 
-# ----------------------------------------------------------------------
-
-class ImmediateFailure(BaseEvent):
-    def __init__(self, item, outcome):
-        self.item = item
-        self.outcome = outcome
-
-class InterruptedExecution(BaseEvent):
-    def __init__(self):
-        self.timeend = timestamp()
-
-class CrashedExecution(BaseEvent):
-    def __init__(self):
-        self.timeend = timestamp()

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	Mon Jul 28 16:02:03 2008
@@ -13,7 +13,7 @@
             passed, skipped, failed = sorter.listoutcomes()
             assert len(failed) == 1
             assert failed[0].repr_path[1].endswith(name) 
-            des = sorter.get(repevent.DeselectedTest)
+            des = sorter.get(repevent.DeselectedItem)
             assert len(des) == 1
 
         for keyword in ['test_one', 'est_on']:
@@ -43,7 +43,7 @@
             assert len(passed) == 1
             assert passed[0].repr_path[1].endswith('test_2')
             assert not skipped 
-            deslist = sorter.get(repevent.DeselectedTest)
+            deslist = sorter.get(repevent.DeselectedItem)
             assert len(deslist) == 1
             assert deslist[0].item.name == 'test_1'
 
@@ -53,7 +53,7 @@
         passed, skipped, failed = sorter.countoutcomes()
         assert passed == 2
         assert skipped == failed == 0
-        deslist = sorter.get(repevent.DeselectedTest)
+        deslist = sorter.get(repevent.DeselectedItem)
         assert len(deslist) == 1
         assert deslist[0].item.name == "test_one" 
 



More information about the pytest-commit mailing list