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

hpk at codespeak.net hpk at codespeak.net
Fri Jul 18 00:19:32 CEST 2008


Author: hpk
Date: Fri Jul 18 00:19:31 2008
New Revision: 56628

Modified:
   py/branch/event/py/test2/executor.py
   py/branch/event/py/test2/present.py
   py/branch/event/py/test2/repevent.py
   py/branch/event/py/test2/testing/suptest.py
   py/branch/event/py/test2/testing/test_present.py
   py/branch/event/py/test2/testing/test_session.py
Log:
* remove redundant ItemFinish event, 
* now there is only the fully serializable 
  ItemTestReport which gets filled directly at test execution time.


Modified: py/branch/event/py/test2/executor.py
==============================================================================
--- py/branch/event/py/test2/executor.py	(original)
+++ py/branch/event/py/test2/executor.py	Fri Jul 18 00:19:31 2008
@@ -31,8 +31,6 @@
         finally:
             outerr = capture.reset()
             self.testrep.iocapture_run = outerr
-            # XXX
-            self.item._run_capture = outerr
 
     def _fillreport(self, excinfo):
         testrep = self.testrep
@@ -52,7 +50,6 @@
             excinfo = py.code.ExceptionInfo()
             if excinfo.errisinstance(Failed) and excinfo.value.excinfo: 
                 excinfo = e.excinfo
-            self.config.bus.notify(repevent.ItemFinish(self.item, excinfo)) 
             self._fillreport(excinfo) 
             if self.config.option.usepdb and not excinfo.errisinstance(Skipped):
                 py.__.test2.custompdb.post_mortem(excinfo._excinfo[2])

Modified: py/branch/event/py/test2/present.py
==============================================================================
--- py/branch/event/py/test2/present.py	(original)
+++ py/branch/event/py/test2/present.py	Fri Jul 18 00:19:31 2008
@@ -33,6 +33,7 @@
 
     def repr_footer(self):
         colitem = self._item 
+        # XXX io capturing is stored with the itemtestreport 
         for parent in colitem.listchain(): 
             if hasattr(parent, '_run_capture'):
                 name, obj = parent._run_capture

Modified: py/branch/event/py/test2/repevent.py
==============================================================================
--- py/branch/event/py/test2/repevent.py	(original)
+++ py/branch/event/py/test2/repevent.py	Fri Jul 18 00:19:31 2008
@@ -47,16 +47,6 @@
         self.item = item
         self.time = timestamp()
 
-from outcome import Skipped 
-class ItemFinish(BaseEvent):
-    def __init__(self, item, excinfo=None):
-        self.item = item
-        self.time = timestamp()
-        self.excinfo = excinfo 
-        self.passed = not excinfo 
-        self.skipped = excinfo and excinfo.errisinstance(Skipped)
-        self.failed = not (self.passed or self.skipped) 
-
 # ----------------------------------------------------------------------
 # Report of the run of a single test (might come from a disttributed run) 
 # ----------------------------------------------------------------------

Modified: py/branch/event/py/test2/testing/suptest.py
==============================================================================
--- py/branch/event/py/test2/testing/suptest.py	(original)
+++ py/branch/event/py/test2/testing/suptest.py	Fri Jul 18 00:19:31 2008
@@ -118,13 +118,11 @@
     p.dirpath("__init__.py").ensure() 
     return p
 
-def getfailing(source):
+def getItemTestReport(source, tb="long"):
     tfile = makeuniquepyfile(source)
-    sorter = events_from_cmdline([tfile])
+    sorter = events_from_cmdline([tfile, "--tb=%s" %tb])
     # get failure base info 
-    failevents = sorter.get(repevent.ItemFinish)
+    failevents = sorter.get(repevent.ItemTestReport)
     assert len(failevents) == 1
-    item = failevents[0].item 
-    excinfo = failevents[0].excinfo 
-    return item, excinfo 
+    return failevents[0],tfile
 

Modified: py/branch/event/py/test2/testing/test_present.py
==============================================================================
--- py/branch/event/py/test2/testing/test_present.py	(original)
+++ py/branch/event/py/test2/testing/test_present.py	Fri Jul 18 00:19:31 2008
@@ -15,36 +15,31 @@
         return present.FuncPresenter(config)
 
     def test_repr_pruning_tb_generated_test(self):
-        item, excinfo = suptest.getfailing("""
+        itemtestreport,fn = suptest.getItemTestReport("""
             def test_gen():
                 def check(x):
                     assert x
                 yield check, 0
         """)
-        s = item.repr_failure(excinfo)
+        s = itemtestreport.repr_failure
         print s
         lines = s.split("\n")
         assert lines[0].find("test_0.test_0.test_gen[0]") != -1
         assert lines[2].find("test_gen[0] -> check(0,)") != -1
         assert lines[3].find("def check(x):") != -1
-        item._config.option.fulltrace = True
-        s = item.repr_failure(excinfo) 
-        lines = s.split("\n")
-        assert lines[2].find("test_gen[0] -> check(0,)") == -1
 
     def test_repr_tb_short(self):
         # XXX probably a redundant test 
-        item, excinfo = suptest.getfailing("""
+        itemtestreport,fn = suptest.getItemTestReport("""
             def f(x):
                 assert x 
             def test_f():
                 f(0)
-        """)
-        item._config.option.tbstyle = "short" 
-        s = item.repr_failure(excinfo)
+        """, tb="short")
+        s = itemtestreport.repr_failure
         print s
         index = -1 
-        basename = item.fspath.basename 
+        basename = fn.basename
         lines = s.split("\n")[2:]
         for line in (
               '  File "%s", line 5, in test_f' % basename, 

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	Fri Jul 18 00:19:31 2008
@@ -194,7 +194,6 @@
         sorter = suptest.events_from_cmdline([p.dirpath(), '--collectonly'])
        
         assert not sorter.get(repevent.ItemStart)
-        assert not sorter.get(repevent.ItemFinish)
         assert not sorter.get(repevent.ItemTestReport) 
         started = sorter.get(repevent.CollectionStart)
         finished = sorter.get(repevent.CollectionFinish)



More information about the pytest-commit mailing list