[py-svn] r63566 - in py/trunk/py/test: . dist dist/testing plugin

hpk at codespeak.net hpk at codespeak.net
Fri Apr 3 16:18:47 CEST 2009


Author: hpk
Date: Fri Apr  3 16:18:47 2009
New Revision: 63566

Modified:
   py/trunk/py/test/dist/dsession.py
   py/trunk/py/test/dist/testing/test_txnode.py
   py/trunk/py/test/dist/txnode.py
   py/trunk/py/test/event.py
   py/trunk/py/test/plugin/api.py
   py/trunk/py/test/plugin/pytest_pytester.py
   py/trunk/py/test/plugin/pytest_resultdb.py
   py/trunk/py/test/plugin/pytest_resultlog.py
   py/trunk/py/test/plugin/pytest_terminal.py
   py/trunk/py/test/pytestplugin.py
   py/trunk/py/test/session.py
Log:
the InternalException event class bites the dust. 



Modified: py/trunk/py/test/dist/dsession.py
==============================================================================
--- py/trunk/py/test/dist/dsession.py	(original)
+++ py/trunk/py/test/dist/dsession.py	Fri Apr  3 16:18:47 2009
@@ -140,7 +140,7 @@
         except KeyboardInterrupt:
             exitstatus = outcome.EXIT_INTERRUPTED
         except:
-            self.bus.notify("internalerror", event.InternalException())
+            self.config.pytestplugins.notify_exception()
             exitstatus = outcome.EXIT_INTERNALERROR
         self.config.bus.unregister(loopstate)
         if exitstatus == 0 and self._testsfailed:

Modified: py/trunk/py/test/dist/testing/test_txnode.py
==============================================================================
--- py/trunk/py/test/dist/testing/test_txnode.py	(original)
+++ py/trunk/py/test/dist/testing/test_txnode.py	Fri Apr  3 16:18:47 2009
@@ -109,7 +109,7 @@
         node = mysetup.makenode(item.config)
         node.channel.close()
         py.test.raises(IOError, "node.send(item)")
-        #ev = self.geteventargs(event.InternalException)
+        #ev = self.getevents("internalerror")
         #assert ev.excinfo.errisinstance(IOError)
 
     def test_send_one(self, testdir, mysetup):

Modified: py/trunk/py/test/dist/txnode.py
==============================================================================
--- py/trunk/py/test/dist/txnode.py	(original)
+++ py/trunk/py/test/dist/txnode.py	Fri Apr  3 16:18:47 2009
@@ -63,7 +63,7 @@
         except:
             excinfo = py.code.ExceptionInfo()
             print "!" * 20, excinfo
-            self.notify("internalerror", event.InternalException(excinfo))
+            self.notify_internal(excinfo)
 
     def send(self, item):
         assert item is not None
@@ -127,7 +127,8 @@
         except KeyboardInterrupt:
             raise
         except:
-            self.sendevent("internalerror", event.InternalException())
+            er = py.code.ExceptionInfo().getrepr(funcargs=True, showlocals=True)
+            self.sendevent("internalerror", excrepr=er)
             raise
 
     def runtest(self, item):

Modified: py/trunk/py/test/event.py
==============================================================================
--- py/trunk/py/test/event.py	(original)
+++ py/trunk/py/test/event.py	Fri Apr  3 16:18:47 2009
@@ -19,23 +19,12 @@
     pass
 
 # ----------------------------------------------------------------------
-# Basic Live Reporting Events 
-# ----------------------------------------------------------------------
-
-class InternalException(BaseEvent):
-    def __init__(self, excinfo=None):
-        if excinfo is None:
-            excinfo = py.code.ExceptionInfo()
-        self.repr = excinfo.getrepr(funcargs=True, showlocals=True)
-
-# ----------------------------------------------------------------------
 # Events related to collecting and executing test Items 
 # ----------------------------------------------------------------------
 
 class Deselected(BaseEvent):
     def __init__(self, items):
         self.items = items 
-        
 
 class BaseReport(BaseEvent):
     def toterminal(self, out):

Modified: py/trunk/py/test/plugin/api.py
==============================================================================
--- py/trunk/py/test/plugin/api.py	(original)
+++ py/trunk/py/test/plugin/api.py	Fri Apr  3 16:18:47 2009
@@ -73,7 +73,7 @@
     def pyevent__trace(self, category, msg):
         """ called for tracing events. """
 
-    def pyevent__internalerror(self, event):
+    def pyevent__internalerror(self, excrepr):
         """ called for internal errors. """
 
     def pyevent__itemstart(self, item, node=None):

Modified: py/trunk/py/test/plugin/pytest_pytester.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_pytester.py	(original)
+++ py/trunk/py/test/plugin/pytest_pytester.py	Fri Apr  3 16:18:47 2009
@@ -264,7 +264,7 @@
         self.__dict__ = locals.copy()
 
     def __repr__(self):
-        return "<Event %r>" %(self.__dict__,)
+        return "<ParsedEvent %r>" %(self.__dict__,)
 
 class EventRecorder(object):
     def __init__(self, pyplugins, debug=False): # True):
@@ -288,6 +288,7 @@
         raise KeyError("popevent: %r not found in %r"  %(name, self.events))
 
     def getevents(self, eventname):
+        """ return list of ParsedEvent instances matching the given eventname. """
         method = self.geteventmethod(eventname)
         l = []
         for event in self.events:

Modified: py/trunk/py/test/plugin/pytest_resultdb.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_resultdb.py	(original)
+++ py/trunk/py/test/plugin/pytest_resultdb.py	Fri Apr  3 16:18:47 2009
@@ -178,10 +178,10 @@
         if not event.passed:
             self.log_outcome(event)
 
-    def pyevent__internalerror(self, event):
-        path = event.repr.reprcrash.path # fishing :(
-        self.write_log_entry(event, '!', path, str(event.repr))
-
+    def pyevent__internalerror(self, excrepr):
+        path = excrepr.reprcrash.path 
+        XXX # we don't have an event
+        self.write_log_entry(event, '!', path, str(excrepr))
 
 SQL_CREATE_TABLES = """
 create table pytest_results (
@@ -368,9 +368,9 @@
         try:
             raise ValueError
         except ValueError:
-            excinfo = event.InternalException()
+            excinfo = py.code.ExceptionInfo()
         reslog = ResultDB(StringIO.StringIO())        
-        reslog.pyevent("internalerror", (excinfo,), {})
+        reslog.pyevent("internalerror", (excinfo.getrepr(),), {})
         entry = reslog.logfile.getvalue()
         entry_lines = entry.splitlines()
 

Modified: py/trunk/py/test/plugin/pytest_resultlog.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_resultlog.py	(original)
+++ py/trunk/py/test/plugin/pytest_resultlog.py	Fri Apr  3 16:18:47 2009
@@ -90,8 +90,9 @@
             if not event.passed:
                 self.log_outcome(event)
         elif eventname == "internalerror":
-            path = event.repr.reprcrash.path # fishing :(
-            self.write_log_entry('!', path, str(event.repr))
+            excrepr = args[0]
+            path = excrepr.reprcrash.path # fishing :(
+            self.write_log_entry('!', path, str(excrepr))
 
 
 # ===============================================================================
@@ -224,9 +225,9 @@
         try:
             raise ValueError
         except ValueError:
-            excinfo = event.InternalException()
+            excinfo = py.code.ExceptionInfo()
         reslog = ResultLog(StringIO.StringIO())        
-        reslog.pyevent("internalerror", (excinfo,), {})
+        reslog.pyevent("internalerror", (excinfo.getrepr(),), {})
         entry = reslog.logfile.getvalue()
         entry_lines = entry.splitlines()
 

Modified: py/trunk/py/test/plugin/pytest_terminal.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_terminal.py	(original)
+++ py/trunk/py/test/plugin/pytest_terminal.py	Fri Apr  3 16:18:47 2009
@@ -82,9 +82,9 @@
         else: 
             return "???", dict(red=True)
 
-    def pyevent__internalerror(self, event):
-        for line in str(event.repr).split("\n"):
-            self.write_line("InternalException: " + line)
+    def pyevent__internalerror(self, excrepr):
+        for line in str(excrepr).split("\n"):
+            self.write_line("INTERNALERROR> " + line)
 
     def pyevent__gwmanage_newgateway(self, gateway, rinfo):
         #self.write_line("%s instantiated gateway from spec %r" %(gateway.id, gateway.spec._spec))
@@ -438,9 +438,9 @@
         modcol = testdir.getmodulecol("def test_one(): pass")
         rep = TerminalReporter(modcol.config, file=linecomp.stringio)
         excinfo = py.test.raises(ValueError, "raise ValueError('hello')")
-        rep.pyevent__internalerror(event.InternalException(excinfo))
+        rep.pyevent__internalerror(excinfo.getrepr())
         linecomp.assert_contains_lines([
-            "InternalException: >*raise ValueError*"
+            "INTERNALERROR> *raise ValueError*"
         ])
 
     def test_gwmanage_events(self, testdir, linecomp):

Modified: py/trunk/py/test/pytestplugin.py
==============================================================================
--- py/trunk/py/test/pytestplugin.py	(original)
+++ py/trunk/py/test/pytestplugin.py	Fri Apr  3 16:18:47 2009
@@ -77,6 +77,12 @@
     def notify(self, eventname, *args, **kwargs):
         return self.pyplugins.notify(eventname, *args, **kwargs)
 
+    def notify_exception(self, excinfo=None):
+        if excinfo is None:
+            excinfo = py.code.ExceptionInfo()
+        excrepr = excinfo.getrepr(funcargs=True, showlocals=True)
+        return self.notify("internalerror", excrepr)
+
     def do_addoption(self, parser):
         methods = self.pyplugins.listattr("pytest_addoption", reverse=True)
         mc = py._com.MultiCall(methods, parser=parser)

Modified: py/trunk/py/test/session.py
==============================================================================
--- py/trunk/py/test/session.py	(original)
+++ py/trunk/py/test/session.py	Fri Apr  3 16:18:47 2009
@@ -121,7 +121,7 @@
             exitstatus = outcome.EXIT_INTERRUPTED
         except:
             captured_excinfo = py.code.ExceptionInfo()
-            self.bus.notify("internalerror", event.InternalException(captured_excinfo))
+            self.config.pytestplugins.notify_exception(captured_excinfo)
             exitstatus = outcome.EXIT_INTERNALERROR
         if exitstatus == 0 and self._testsfailed:
             exitstatus = outcome.EXIT_TESTSFAILED



More information about the pytest-commit mailing list