[py-svn] r61997 - in py/branch/pytestplugin/py/test: . plugin

hpk at codespeak.net hpk at codespeak.net
Wed Feb 18 11:03:07 CET 2009


Author: hpk
Date: Wed Feb 18 11:03:06 2009
New Revision: 61997

Modified:
   py/branch/pytestplugin/py/test/plugin/pytest_terminal.py
   py/branch/pytestplugin/py/test/session.py
Log:
yay, finally got rid of the old-style generic event catcher
in favour of specifiy keyword based events 


Modified: py/branch/pytestplugin/py/test/plugin/pytest_terminal.py
==============================================================================
--- py/branch/pytestplugin/py/test/plugin/pytest_terminal.py	(original)
+++ py/branch/pytestplugin/py/test/plugin/pytest_terminal.py	Wed Feb 18 11:03:06 2009
@@ -23,15 +23,6 @@
                 setattr(self.reporter._tw, name, getattr(config, attr))
         config.bus.subscribe_methods(self.reporter)
 
-    def pytest_event(self, (name, event)):
-        #print "processing event", event
-        #print "looking for", name
-        evname = event.__class__.__name__ 
-        repmethod = getattr(self.reporter, "rep_%s" % evname, None)
-        if repmethod is not None:
-            #print "calling", repmethod, event
-            repmethod(event)
-
 def folded_skips(skipped):
     d = {}
     for event in skipped:
@@ -186,7 +177,7 @@
         for i, testarg in py.builtin.enumerate(self.config.args):
             self.write_line("test object %d: %s" %(i+1, testarg))
 
-    def rep_TestrunFinish(self, ev):
+    def pyevent_testrunfinish(self, ev):
         self._tw.line("")
         if ev.exitstatus in (0, 1, 2):
             self.summary_failures()
@@ -301,7 +292,7 @@
             self.outindent("!!! %s !!!" % ev.longrepr.reprcrash.message)
         self.indent = self.indent[:-len(self.INDENT)]
 
-    def rep_TestrunFinish(self, session):
+    def pyevent_testrunfinish(self, session):
         for ev in self._failed:
             ev.toterminal(self.out)
                 
@@ -633,10 +624,5 @@
         py.magic.revert(sys, 'version_info') 
 
 def registerdispatcher(rep):
-    def dispatch((name, event)):
-        meth = getattr(rep, "rep_" + event.__class__.__name__, None)
-        if meth is not None:
-            meth(event)
-    rep.config.bus._bus.subscribe(dispatch)
     rep.config.bus.subscribe_methods(rep)
 

Modified: py/branch/pytestplugin/py/test/session.py
==============================================================================
--- py/branch/pytestplugin/py/test/session.py	(original)
+++ py/branch/pytestplugin/py/test/session.py	Wed Feb 18 11:03:06 2009
@@ -99,7 +99,7 @@
 
     def sessionfinishes(self, exitstatus=0, excinfo=None):
         """ teardown any resources after a test run. """ 
-        self.bus.notify(sessionfinishes=event.TestrunFinish(exitstatus=exitstatus,
+        self.bus.notify(testrunfinish=event.TestrunFinish(exitstatus=exitstatus,
                                             excinfo=excinfo))
         self.bus.unsubscribe(self._processfailures)
         return self._failurelist 



More information about the pytest-commit mailing list