[py-svn] r62042 - in py/branch/pytestplugin/py: . misc misc/testing test test/plugin test/testing
hpk at codespeak.net
hpk at codespeak.net
Fri Feb 20 02:44:17 CET 2009
Author: hpk
Date: Fri Feb 20 02:44:14 2009
New Revision: 62042
Removed:
py/branch/pytestplugin/py/misc/event.py
py/branch/pytestplugin/py/misc/plugin.py
py/branch/pytestplugin/py/misc/testing/test_event.py
py/branch/pytestplugin/py/misc/testing/test_plugin.py
Modified:
py/branch/pytestplugin/py/__init__.py
py/branch/pytestplugin/py/_com.py
py/branch/pytestplugin/py/initpkg.py
py/branch/pytestplugin/py/misc/testing/test_com.py
py/branch/pytestplugin/py/misc/testing/test_warn.py
py/branch/pytestplugin/py/misc/warn.py
py/branch/pytestplugin/py/test/config.py
py/branch/pytestplugin/py/test/event.py
py/branch/pytestplugin/py/test/handleplugin.py
py/branch/pytestplugin/py/test/plugin/pytest_terminal.py
py/branch/pytestplugin/py/test/pycollect.py
py/branch/pytestplugin/py/test/testing/test_config.py
py/branch/pytestplugin/py/test/testing/test_handleplugin.py
Log:
* get rid of old global py.event/py.plugin in favour of the new py._com arrangement
* experimental: allow to optionally receive a "call" argument
Modified: py/branch/pytestplugin/py/__init__.py
==============================================================================
--- py/branch/pytestplugin/py/__init__.py (original)
+++ py/branch/pytestplugin/py/__init__.py Fri Feb 20 02:44:14 2009
@@ -56,9 +56,6 @@
exportdefs = {
# py lib events and plugins
- 'event' : ('./misc/event.py', 'eventbus'),
- 'plugin' : ('./misc/plugin.py', 'plugin'),
-
'_com.PluginManager' : ('./_com.py', 'PluginManager'),
'_com.EventBus' : ('./_com.py', 'EventBus'),
'_com.Call' : ('./_com.py', 'Call'),
@@ -203,6 +200,6 @@
})
import py
-py.plugin.consider_env()
+py._com.pluginmanager.consider_env()
Modified: py/branch/pytestplugin/py/_com.py
==============================================================================
--- py/branch/pytestplugin/py/_com.py (original)
+++ py/branch/pytestplugin/py/_com.py Fri Feb 20 02:44:14 2009
@@ -2,7 +2,7 @@
import py
class Call:
- NORESULT = object()
+ NONEASRESULT = object()
def __init__(self, callees, methname, *args, **kwargs):
self.callees = list(callees)
@@ -23,9 +23,15 @@
def execute(self, firstresult=False):
self.methods = self.listmethods()
while self.methods:
- self.currentmethod = self.methods.pop(0)
- res = self.currentmethod(self, *self.args, **self.kwargs)
- if res is not self.NORESULT:
+ self.currentmethod = self.methods.pop()
+ varnames = self.currentmethod.im_func.func_code.co_varnames
+ if varnames >1 and varnames[1] == 'call':
+ res = self.currentmethod(self, *self.args, **self.kwargs)
+ else:
+ res = self.currentmethod(*self.args, **self.kwargs)
+ if res is not None:
+ if res is self.NONEASRESULT:
+ res = None
self.results.append(res)
if firstresult:
break
Modified: py/branch/pytestplugin/py/initpkg.py
==============================================================================
--- py/branch/pytestplugin/py/initpkg.py (original)
+++ py/branch/pytestplugin/py/initpkg.py Fri Feb 20 02:44:14 2009
@@ -273,5 +273,5 @@
ENVKEY = pkgname.upper() + "_AUTOIMPORT"
if ENVKEY in os.environ:
for impname in os.environ[ENVKEY].split(","):
- py.event.notify(autoimport=impname)
+ py._com.bus.notify(autoimport=impname)
__import__(impname)
Deleted: /py/branch/pytestplugin/py/misc/event.py
==============================================================================
--- /py/branch/pytestplugin/py/misc/event.py Fri Feb 20 02:44:14 2009
+++ (empty file)
@@ -1,42 +0,0 @@
-
-class EventBus(object):
- """ Event Bus for distributing named and unnamed events. """
- def __init__(self):
- self._subscribers = {}
-
- def _getsubscribers(self, key):
- try:
- return self._subscribers[key]
- except KeyError:
- x = self._subscribers[key] = []
- return x
-
- def subscribe(self, callback=None, **kwcallback):
- """ subscribe callback to bus events. """
- if callback:
- self._getsubscribers('').append(callback)
- assert not kwcallback
- else:
- assert len(kwcallback) == 1
- name, call = kwcallback.popitem()
- self._getsubscribers(name).append(call)
-
- def unsubscribe(self, callback=None, **kwcallback):
- """ unsubscribe given callback from bus events. """
- try:
- if callback is not None:
- self._getsubscribers('').remove(callback)
- else:
- for name, call in kwcallback.items():
- self._getsubscribers(name).remove(call)
- except ValueError, e:
- raise KeyError(*e.args)
-
- def notify(self, **kw):
- for name in kw:
- for callback in self._getsubscribers(name):
- callback(kw[name])
- for callback in self._getsubscribers(''):
- callback((name, kw[name]))
-
-eventbus = EventBus()
Deleted: /py/branch/pytestplugin/py/misc/plugin.py
==============================================================================
--- /py/branch/pytestplugin/py/misc/plugin.py Fri Feb 20 02:44:14 2009
+++ (empty file)
@@ -1,69 +0,0 @@
-import py
-
-class PluginManager:
- _pyspec = "pylib"
-
- def __init__(self, bus=None):
- if bus is None:
- from py.__.misc.event import EventBus
- bus = EventBus()
- self._bus = bus
- self.list = []
-
- def import_module(self, modspec):
- # XXX allow modspec to specify version / lookup
- modpath = modspec
- self._bus.notify(importingmodule=modpath)
- __import__(modpath)
-
- def consider_env(self):
- """ consider ENV variables for loading modules. """
- val = py.std.os.environ.get(self._pyspec.upper(), None)
- self._consider(val)
-
- def consider_module(self, mod):
- speclist = getattr(mod, self._pyspec, None)
- self._consider(speclist)
-
- def _consider(self, speclist):
- if speclist is not None:
- if not isinstance(speclist, (list, tuple)):
- speclist = (speclist,)
- for spec in speclist:
- self.import_module(spec)
-
- def register(self, plugin):
- assert not isinstance(plugin, str)
- self.list.append(plugin)
- #print "registering", self, plugin
- self._bus.notify(pluginregistered=plugin)
-
- def iterattr(self, attrname):
- for plugin in self.list:
- try:
- yield getattr(plugin, attrname)
- except AttributeError:
- continue
-
- def calleach(self, methname, *args, **kwargs):
- ret = []
- for call in self.iterattr(methname):
- result = call(*args, **kwargs)
- ret.append(result)
- return ret
-
- def callfirst(self, methname, *args, **kwargs):
- ret = []
- for call in self.iterattr(methname):
- result = call(*args, **kwargs)
- if result is not None: # XXX odd to interpret the result here
- ret.append(result)
- break
- return ret
-
- def callone(self, plugin, methname, *args, **kwargs):
- call = getattr(plugin, methname, None)
- if call is not None:
- return call(*args, **kwargs)
-
-plugin = PluginManager(bus=py.event)
Modified: py/branch/pytestplugin/py/misc/testing/test_com.py
==============================================================================
--- py/branch/pytestplugin/py/misc/testing/test_com.py (original)
+++ py/branch/pytestplugin/py/misc/testing/test_com.py Fri Feb 20 02:44:14 2009
@@ -10,16 +10,16 @@
class P1:
def m(self, call, x):
assert call.currentmethod == self.m
- assert call.results == []
- assert call.methods
+ assert len(call.results) == 1
+ assert not call.methods
return 17
class P2:
def m(self, call, x):
assert call.currentmethod == self.m
assert call.args
- assert len(call.results) == 1
- assert not call.methods
+ assert call.results == []
+ assert call.methods
return 23
p1 = P1()
@@ -27,7 +27,16 @@
call = Call([p1, p2], 'm', 23)
reslist = call.execute()
assert len(reslist) == 2
- assert reslist == [17, 23]
+ # ensure reversed order
+ assert reslist == [23, 17]
+
+ def test_optionalcallarg(self):
+ class P1:
+ def m(self, x):
+ return x
+ call = Call([P1()], 'm', 23)
+ assert call.execute() == [23]
+ assert call.execute(firstresult=True) == 23
class TestPluginManager:
def test_register(self):
@@ -65,7 +74,7 @@
res = pm.call_firstresult("m", x=5)
assert pm.call_firstresult("notexist") is None
- assert res == 5
+ assert res == 33
reslist = pm.call_each("m", x=5)
assert len(reslist) == 2
assert 5 in reslist
@@ -75,7 +84,7 @@
assert pm.callplugin(api1(), 'm', x=12) == 12
assert pm.callplugin(api2(), 't') is None
- def test_callfirst_ignores_None(self):
+ def test_call_none_is_no_result(self):
pm = PluginManager()
class api1:
def m(self, call):
@@ -85,25 +94,19 @@
return 41
pm.register(api1())
pm.register(api1())
- pm.register(api1())
pm.register(api2())
- pm.register(api1())
- pm.register(api1())
- assert pm.call_firstresult('m') == None
+ assert pm.call_firstresult('m') == 41
+ assert pm.call_each('m') == [41]
- def test_callsetnoresult(self):
+ def test_call_noneasresult(self):
pm = PluginManager()
class api1:
def m(self, call):
- return call.NORESULT
- class api2:
- def m(self, call):
- return 41
+ return call.NONEASRESULT
pm.register(api1())
pm.register(api1())
- pm.register(api2())
- assert pm.call_firstresult('m') == 41
- assert pm.call_each('m') == [41]
+ assert pm.call_firstresult('m') is None
+ assert pm.call_each('m') == [None, None]
def test_iterattr(self):
pm = PluginManager()
Deleted: /py/branch/pytestplugin/py/misc/testing/test_event.py
==============================================================================
--- /py/branch/pytestplugin/py/misc/testing/test_event.py Fri Feb 20 02:44:14 2009
+++ (empty file)
@@ -1,72 +0,0 @@
-
-import py
-from py.__.misc.event import EventBus
-
-class TestEventBus:
- def test_kw_register_notify_unregister(self):
- bus = EventBus()
- l = []
- bus.subscribe(hello=l.append)
- bus.notify(some=1)
- assert not l
- bus.notify(hello=5)
- assert len(l) == 1
- l.remove(5)
- bus.unsubscribe(hello=l.append)
- bus.notify(hello=7)
- assert not l
-
- def test_kw_unregister_non_existing(self):
- bus = EventBus()
- py.test.raises(KeyError, "bus.unsubscribe(hello=42)")
- bus.subscribe(hello=10)
- bus.unsubscribe(hello=10)
- py.test.raises(KeyError, "bus.unsubscribe(hello=42)")
-
- def test_kw_multiregister(self):
- bus = EventBus()
- l1 = []
- l2 = []
- bus.subscribe(hello=l1.append)
- bus.subscribe(hello=l2.append)
- bus.subscribe(world=l2.append)
- bus.notify(some=1)
- assert not l1 and not l2
- bus.notify(hello=5)
- assert len(l1) == 1
- assert len(l2) == 1
- bus.notify(world=42)
- assert len(l2) == 2
- bus.unsubscribe(hello=l2.append)
- bus.unsubscribe(world=l2.append)
- bus.unsubscribe(hello=l1.append)
-
- def test_simple_anonymous(self):
- bus = EventBus()
- l = []
- bus.subscribe(l.append)
- bus.notify(hello=1)
- assert l == [("hello", 1)]
- bus.unsubscribe(l.append)
- bus.notify(hello=1)
- assert l == [("hello", 1)]
-
- def test_multi_anonymous(self):
- bus = EventBus()
- l1 = []
- l2 = []
- bus.subscribe(l1.append)
- bus.subscribe(l2.append)
- bus.notify(event=1)
- bus.notify(event2=2)
- bus.notify(event3=3)
- assert l1 == [("event", 1), ("event2", 2), ("event3", 3)]
- assert l2 == [("event", 1), ("event2", 2), ("event3", 3)]
- bus.unsubscribe(l1.append)
- bus.unsubscribe(l2.append)
- py.test.raises(KeyError, "bus.unsubscribe(l1.append)")
- py.test.raises(KeyError, "bus.unsubscribe(l2.append)")
-
-
-def test_api():
- assert isinstance(py.event, EventBus)
Deleted: /py/branch/pytestplugin/py/misc/testing/test_plugin.py
==============================================================================
--- /py/branch/pytestplugin/py/misc/testing/test_plugin.py Fri Feb 20 02:44:14 2009
+++ (empty file)
@@ -1,134 +0,0 @@
-
-import py
-import os
-from py.__.misc.plugin import PluginManager
-pytest_plugins = "xfail"
-
-class TestPluginManager:
- def test_register(self):
- pm = PluginManager()
- class MyPlugin:
- pass
- my = MyPlugin()
- pm.register(my)
- assert my in pm.list
-
- @py.test.keywords(xfail=True)
- def test_onregister(self):
- pm = PluginManager()
- l = []
- class MyApi:
- def pyevent_pluginregistered(self, plugin):
- l.append(plugin)
- myapi = MyApi()
- pm.register(myapi)
- assert len(l) == 1
- assert l[0] is myapi
-
- def test_calleach(self):
- pm = PluginManager()
- class api1:
- def m(self):
- return 42
- class api2:
- def m(self):
- return 41
- pm.register(api1())
- pm.register(api2())
- l = pm.calleach('m')
- l.sort()
- assert l == [41, 42]
-
- def test_callfirst(self):
- pm = PluginManager()
- class api1:
- def m(self):
- return 42
- class api2:
- def m(self):
- return 41
- pm.register(api1())
- pm.register(api2())
- l = pm.callfirst('m')
- assert l == [42]
-
- def test_callfirst_ignores_None(self):
- pm = PluginManager()
- class api1:
- def m(self):
- return None
- class api2:
- def m(self):
- return 41
- pm.register(api1())
- pm.register(api1())
- pm.register(api1())
- pm.register(api2())
- pm.register(api1())
- pm.register(api1())
- l = pm.callfirst('m')
- assert l == [41]
-
-
- def test_iterattr(self):
- pm = PluginManager()
- class api1:
- x = 42
- class api2:
- x = 41
- pm.register(api1())
- pm.register(api2())
- l = list(pm.iterattr('x'))
- l.sort()
- assert l == [41, 42]
-
- def test_consider_env(self):
- # XXX write a helper for preserving os.environ
- pm = PluginManager()
- KEY = "PYLIB"
- old = os.environ.get(KEY, None)
- try:
- os.environ[KEY] = "unknownconsider_env"
- py.test.raises(ImportError, "pm.consider_env()")
- finally:
- if old is None:
- del os.environ[KEY]
- else:
- os.environ[KEY] = old
-
- def test_consider_module(self):
- pm = PluginManager()
- mod = py.std.new.module("temp")
- mod.pylib = ["xxx nomod"]
- excinfo = py.test.raises(ImportError, "pm.consider_module(mod)")
- mod.pylib = "os"
- l = []
- pm._bus.subscribe(importingmodule=l.append)
- pm.consider_module(mod)
- assert len(l) == 1
- assert l[0] == mod.pylib
-
-def test_api_and_defaults():
- assert isinstance(py.plugin, PluginManager)
- assert py.plugin._bus is py.event
-
-def test_subprocess_env():
- # XXX write a helper for preserving os.environ
- pm = PluginManager()
- KEY = "PYLIB"
- old = os.environ.get(KEY, None)
- olddir = py.path.local(py.__file__).dirpath().dirpath().chdir()
- try:
- os.environ[KEY] = "unknownconsider_env"
- excinfo = py.test.raises(py.process.cmdexec.Error, """
- py.process.cmdexec("python -c 'import py'")
- """)
- assert str(excinfo.value).find("ImportError") != -1
- assert str(excinfo.value).find("unknownconsider") != -1
- finally:
- olddir.chdir()
- if old is None:
- del os.environ[KEY]
- else:
- os.environ[KEY] = old
-
Modified: py/branch/pytestplugin/py/misc/testing/test_warn.py
==============================================================================
--- py/branch/pytestplugin/py/misc/testing/test_warn.py (original)
+++ py/branch/pytestplugin/py/misc/testing/test_warn.py Fri Feb 20 02:44:14 2009
@@ -49,4 +49,4 @@
def test_default():
from py.__.misc.warn import APIWARN
- assert APIWARN.im_self._eventbus is py.event
+ assert APIWARN.im_self._eventbus is py._com.bus
Modified: py/branch/pytestplugin/py/misc/warn.py
==============================================================================
--- py/branch/pytestplugin/py/misc/warn.py (original)
+++ py/branch/pytestplugin/py/misc/warn.py Fri Feb 20 02:44:14 2009
@@ -11,11 +11,11 @@
def __str__(self):
return self.msg
-# XXX probably only apiwarn() + py.event forwarding
+# XXX probably only apiwarn() + py._com.bus forwarding
# warn_explicit is actually needed
class WarningBus(object):
- def __init__(self, eventbus=py.event):
+ def __init__(self, eventbus=py._com.bus):
self._eventbus = eventbus
def subscribe(self, callable):
Modified: py/branch/pytestplugin/py/test/config.py
==============================================================================
--- py/branch/pytestplugin/py/test/config.py (original)
+++ py/branch/pytestplugin/py/test/config.py Fri Feb 20 02:44:14 2009
@@ -75,8 +75,8 @@
def _initafterpickle(self, topdir):
self.__init__(
#issue1
- #bus=py.test._EventBus(bus=py.event),
- #pluginmanager=py.test._PytestPluginManager(py.plugin)
+ #bus=py.test._EventBus(bus=py._com.bus),
+ #pluginmanager=py.test._PytestPluginManager(py._com.pluginmanager)
)
self._initialized = True
self.topdir = py.path.local(topdir)
@@ -264,8 +264,9 @@
# this is the one per-process instance of py.test configuration
config_per_process = Config(
- bus=py.test._EventBus(bus=py.event),
- pluginmanager=py.test._PytestPluginManager(py.plugin))
+ bus=py.test._EventBus(bus=py._com.bus),
+ pluginmanager=py.test._PytestPluginManager(py._com.pluginmanager)
+)
# default import paths for sessions
Modified: py/branch/pytestplugin/py/test/event.py
==============================================================================
--- py/branch/pytestplugin/py/test/event.py (original)
+++ py/branch/pytestplugin/py/test/event.py Fri Feb 20 02:44:14 2009
@@ -5,13 +5,12 @@
import py
import time
from py.__.test.outcome import Skipped
-import py.__.misc.event
class EventBus(object):
""" Bus for distributing events. """
def __init__(self, bus=None):
if bus is None:
- bus = py.__.misc.event.EventBus()
+ bus = py._com.EventBus()
self._bus = bus
self._memo = []
Modified: py/branch/pytestplugin/py/test/handleplugin.py
==============================================================================
--- py/branch/pytestplugin/py/test/handleplugin.py (original)
+++ py/branch/pytestplugin/py/test/handleplugin.py Fri Feb 20 02:44:14 2009
@@ -5,9 +5,8 @@
class PytestPluginManager(object):
def __init__(self, pm=None, _bus=None):
- from py.__.misc.plugin import PluginManager
if pm is None:
- pm = PluginManager(bus=_bus)
+ pm = py._com.PluginManager(bus=_bus)
#assert isinstance(pm, PluginManager)
self.pm = pm
self._plugins = {}
@@ -52,11 +51,11 @@
for x in self.pm.iterattr(methname):
return x
- def callfirst(self, *args, **kwargs):
- return self.pm.callfirst(*args, **kwargs)
+ def call_firstresult(self, *args, **kwargs):
+ return self.pm.call_firstresult(*args, **kwargs)
- def calleach(self, *args, **kwargs):
- return self.pm.calleach(*args, **kwargs)
+ def call_each(self, *args, **kwargs):
+ return self.pm.call_each(*args, **kwargs)
def add_cmdlineoptions(self, config):
@@ -69,18 +68,18 @@
def configure(self, config):
def configureplugin(plugin):
- self.pm.callone(plugin, "pytest_configure", config=config)
+ self.pm.callplugin(plugin, "pytest_configure", config=config)
if hasattr(plugin, 'pytest_event'):
config.bus._bus.subscribe(plugin.pytest_event)
config.bus.subscribe_methods(plugin)
self._configureplugin = configureplugin
config.bus.subscribe(pluginregistered=self._configureplugin)
- for plugin in self.pm.list:
+ for plugin in self.pm.plugins:
configureplugin(plugin)
def unconfigure(self, config):
- for plugin in self.pm.list:
- self.pm.callone(plugin, "pytest_unconfigure", config=config)
+ for plugin in self.pm.plugins:
+ self.pm.callplugin(plugin, "pytest_unconfigure", config=config)
config.bus.close()
del self._configureplugin
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 Fri Feb 20 02:44:14 2009
@@ -65,9 +65,9 @@
self._tw.sep(sep, title, **markup)
def getcategoryletterword(self, event):
- reslist = self.config.pluginmanager.callfirst("pytest_report_teststatus", event=event)
- if reslist:
- return reslist[0]
+ res = self.config.pluginmanager.call_firstresult("pytest_report_teststatus", event=event)
+ if res:
+ return res
for cat in 'skipped failed passed ???'.split():
if getattr(event, cat, None):
break
@@ -169,7 +169,7 @@
if ev.exitstatus in (0, 1, 2):
self.summary_failures()
self.summary_skips()
- self.config.pluginmanager.calleach("pytest_terminal_summary", terminalreporter=self)
+ self.config.pluginmanager.call_each("pytest_terminal_summary", terminalreporter=self)
if ev.excrepr is not None:
self.summary_final_exc(ev.excrepr)
if ev.exitstatus == 2:
Modified: py/branch/pytestplugin/py/test/pycollect.py
==============================================================================
--- py/branch/pytestplugin/py/test/pycollect.py (original)
+++ py/branch/pytestplugin/py/test/pycollect.py Fri Feb 20 02:44:14 2009
@@ -137,10 +137,10 @@
return self.join(name)
def makeitem(self, name, obj):
- reslist = self._config.pluginmanager.callfirst(
+ res = self._config.pluginmanager.call_firstresult(
"pytest_pymodule_makeitem", modcol=self, name=name, obj=obj)
- if reslist:
- return reslist[0]
+ if res:
+ return res
if (self.classnamefilter(name)) and \
py.std.inspect.isclass(obj):
res = self._deprecated_join(name)
@@ -355,23 +355,23 @@
def fillarg(self, argname, kwargs):
value = argfinalizer = None
- if hasattr(self.parent.obj, 'pytest_pyfunc_arg'):
- result = self.parent.obj.pytest_pyfunc_arg(pyfuncitem=self, argname=argname)
- if result:
- value, argfinalizer = result
- if value is None:
- reslist = self._config.pluginmanager.callfirst(
- "pytest_pyfunc_arg", pyfuncitem=self, argname=argname)
- if reslist:
- value, argfinalizer = reslist[0]
- else:
- print "pluginmanager is", self._config.pluginmanager
- print "could not find argument %r, plugins=%r" %(
- argname,self._config.pluginmanager._plugins)
- raise TypeError("could not provide funcargument %r" %(argname,))
- kwargs[argname] = value
- if argfinalizer is not None:
- self._argfinalizers.append(argfinalizer)
+ call = py._com.Call(
+ self._config.pluginmanager.pm.plugins + [self.parent.obj],
+ "pytest_pyfunc_arg", pyfuncitem=self, argname=argname
+ )
+ res = call.execute(firstresult=True)
+ if res:
+ value, argfinalizer = res
+ kwargs[argname] = value
+ if argfinalizer is not None:
+ self._argfinalizers.append(argfinalizer)
+ else:
+ print "pluginmanager is", self._config.pluginmanager
+ print "could not find argument %r, plugins=%r" %(
+ argname,self._config.pluginmanager._plugins)
+ for x in call.methods:
+ print x
+ raise TypeError("could not provide funcargument %r" %(argname,))
def __eq__(self, other):
try:
Modified: py/branch/pytestplugin/py/test/testing/test_config.py
==============================================================================
--- py/branch/pytestplugin/py/test/testing/test_config.py (original)
+++ py/branch/pytestplugin/py/test/testing/test_config.py Fri Feb 20 02:44:14 2009
@@ -115,8 +115,8 @@
# have correct plugin initialization
#XXX assert config2.pluginmanager.pm._plugins
#XXX assert config2.bus.issubscribed(config2.pluginmanager.forward_event)
- assert config2.bus._bus == py.event
- assert config2.pluginmanager.pm == py.plugin
+ assert config2.bus._bus == py._com.bus
+ assert config2.pluginmanager.pm == py._com.pluginmanager
def test_config_initafterpickle_some():
tmp = py.test.ensuretemp("test_config_initafterpickle_some")
@@ -465,5 +465,5 @@
assert newcol2.fspath.relto(topdir)
def test_default_bus():
- assert py.test.config.bus._bus is py.event
+ assert py.test.config.bus._bus is py._com.bus
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 Fri Feb 20 02:44:14 2009
@@ -84,7 +84,7 @@
aplugin = testdir.makepyfile(pytest_a="""class A: pass""")
pm = PytestPluginManager()
l = []
- pm.pm._bus.subscribe(pluginregistered=l.append)
+ pm.pm.bus.subscribe(pluginregistered=l.append)
#syspath.prepend(aplugin.dirpath())
py.std.sys.path.insert(0, str(aplugin.dirpath()))
pm.consider_module(mod)
@@ -92,7 +92,6 @@
assert len(l) == 1
pm.consider_module(mod)
assert len(l) == 1
-
import os, sys
import py
@@ -224,7 +223,7 @@
pm.callplugins("method", arg=42)
py.test.raises(TypeError, 'pm.callplugins("method", arg=42, s=13)')
- def test_callfirst(self):
+ def test_call_firstresult(self):
pm = PytestPluginManager()
class My1:
def method(self):
@@ -235,14 +234,14 @@
class My3:
def method(self):
return None
- assert pm.callfirst("method") is None
- assert pm.callfirst("methodnotexists") is None
+ assert pm.call_firstresult("method") is None
+ assert pm.call_firstresult("methodnotexists") is None
pm.addpluginclass(My1)
- assert pm.callfirst("method") is None
+ assert pm.call_firstresult("method") is None
pm.addpluginclass(My2)
- assert pm.callfirst("method") == True
+ assert pm.call_firstresult("method") == True
pm.addpluginclass(My3)
- assert pm.callfirst("method") == True
+ assert pm.call_firstresult("method") == True
def test_listattr(self):
pm = PytestPluginManager()
More information about the pytest-commit
mailing list