[py-svn] r61980 - in py/branch/pytestplugin/py: misc misc/testing test test/testing

hpk at codespeak.net hpk at codespeak.net
Tue Feb 17 19:50:20 CET 2009


Author: hpk
Date: Tue Feb 17 19:50:17 2009
New Revision: 61980

Modified:
   py/branch/pytestplugin/py/misc/plugin.py
   py/branch/pytestplugin/py/misc/testing/test_plugin.py
   py/branch/pytestplugin/py/test/handleplugin.py
   py/branch/pytestplugin/py/test/testing/test_handleplugin.py
Log:
subscribe pyevent_NAME methods from test plugins directly


Modified: py/branch/pytestplugin/py/misc/plugin.py
==============================================================================
--- py/branch/pytestplugin/py/misc/plugin.py	(original)
+++ py/branch/pytestplugin/py/misc/plugin.py	Tue Feb 17 19:50:17 2009
@@ -9,10 +9,6 @@
             bus = EventBus()
         self._bus = bus 
         self.list = []
-        self._bus.subscribe(self._forwardevent)
-
-    def _forwardevent(self, (name, obj)):
-        self.calleach("pyevent_" + name, obj)
 
     def import_module(self, modspec):
         # XXX allow modspec to specify version / lookup 

Modified: py/branch/pytestplugin/py/misc/testing/test_plugin.py
==============================================================================
--- py/branch/pytestplugin/py/misc/testing/test_plugin.py	(original)
+++ py/branch/pytestplugin/py/misc/testing/test_plugin.py	Tue Feb 17 19:50:17 2009
@@ -2,6 +2,7 @@
 import py
 import os
 from py.__.misc.plugin import PluginManager
+pytest_plugins = "xfail"
  
 class TestPluginManager:
     def test_register(self):
@@ -12,6 +13,7 @@
         pm.register(my)
         assert my in pm.list
 
+    @py.test.keywords(xfail=True)
     def test_onregister(self):
         pm = PluginManager()
         l = []

Modified: py/branch/pytestplugin/py/test/handleplugin.py
==============================================================================
--- py/branch/pytestplugin/py/test/handleplugin.py	(original)
+++ py/branch/pytestplugin/py/test/handleplugin.py	Tue Feb 17 19:50:17 2009
@@ -72,7 +72,7 @@
             self.pm.callone(plugin, "pytest_configure", config=config)
             if hasattr(plugin, 'pytest_event'):
                 config.bus._bus.subscribe(plugin.pytest_event)
-            #self.bus.subscribe_methods(plugin) 
+            config.bus.subscribe_methods(plugin) 
         self._configureplugin = configureplugin
         config.bus.subscribe(pluginregistered=self._configureplugin)
         for plugin in self.pm.list:

Modified: py/branch/pytestplugin/py/test/testing/test_handleplugin.py
==============================================================================
--- py/branch/pytestplugin/py/test/testing/test_handleplugin.py	(original)
+++ py/branch/pytestplugin/py/test/testing/test_handleplugin.py	Tue Feb 17 19:50:17 2009
@@ -19,9 +19,13 @@
     config = pytestConfig()
     pp = config.pluginmanager
     l = []
+    events = []
     class A:
         def pytest_configure(self, config):
             l.append(self)
+        def pyevent_hello(self, obj):
+            events.append(obj)
+            
     pp.pm.register(A())
     assert len(l) == 0
     pp.configure(config=config)
@@ -29,10 +33,14 @@
     pp.pm.register(A())
     assert len(l) == 2
     assert l[0] != l[1]
+    
+    config.bus.notify(hello=42)
+    assert len(events) == 2
+    assert events == [42,42]
+
     pp.unconfigure(config=config)
     pp.pm.register(A())
     assert len(l) == 2
-    
 
 def test_addcmdlineoptions():
     class PseudoPM:
@@ -70,6 +78,7 @@
     py.test.raises(ImportError, "importplugin('laksjd.qwe')")
     mod = importplugin("pytest_terminal")
     assert mod == py.__.test.plugin.pytest_terminal 
+
     
 import os, sys
 import py



More information about the pytest-commit mailing list