[svn r63911] striking unneeded call_each from pluginmanager

--HG--
branch : trunk
This commit is contained in:
hpk 2009-04-09 20:39:59 +02:00
parent f319a84503
commit 73529ce63d
5 changed files with 14 additions and 31 deletions

View File

@ -443,8 +443,7 @@ class Directory(FSCollector):
def consider_dir(self, path, usefilters=None):
if usefilters is not None:
APIWARN("0.99", "usefilters argument not needed")
res = self.config.pluginmanager.call_firstresult(
'pytest_collect_recurse', path=path, parent=self)
res = self.config.api.pytest_collect_recurse(path=path, parent=self)
if res is None or res:
return self.config.api.pytest_collect_directory(
path=path, parent=self)

View File

@ -44,6 +44,7 @@ class PluginHooks:
""" return True/False to cause/prevent recursion into given directory.
return None if you do not want to make the decision.
"""
pytest_collect_recurse.firstresult = True
def pytest_collect_directory(self, path, parent):
""" return Collection node or None. """

View File

@ -106,7 +106,7 @@ def test_callrecorder_basic():
def xyz(self, arg):
pass
rec.start_recording(ApiClass)
comregistry.call_each("xyz", 123)
rec.api.xyz(arg=123)
call = rec.popcall("xyz")
assert call.arg == 123
assert call._name == "xyz"
@ -124,7 +124,7 @@ def test_functional(testdir, linecomp):
def xyz(self, arg):
return arg + 1
rec._comregistry.register(Plugin())
res = rec._comregistry.call_firstresult("xyz", 41)
assert res == 42
res = rec.api.xyz(arg=41)
assert res == [42]
""")
sorter.assertoutcome(passed=1)

View File

@ -79,16 +79,12 @@ class PluginManager(object):
for x in self.comregistry.listattr(attrname):
return x
def listattr(self, attrname):
return self.comregistry.listattr(attrname)
def listattr(self, attrname, plugins=None):
return self.comregistry.listattr(attrname, plugins=plugins)
def call_firstresult(self, *args, **kwargs):
return self.comregistry.call_firstresult(*args, **kwargs)
def call_each(self, *args, **kwargs):
#print "plugins.call_each", args[0], args[1:], kwargs
return self.comregistry.call_each(*args, **kwargs)
def notify_exception(self, excinfo=None):
if excinfo is None:
excinfo = py.code.ExceptionInfo()
@ -102,8 +98,12 @@ class PluginManager(object):
def pytest_plugin_registered(self, plugin):
if hasattr(self, '_config'):
self.comregistry.call_plugin(plugin, "pytest_addoption", parser=self._config._parser)
self.comregistry.call_plugin(plugin, "pytest_configure", config=self._config)
self.call_plugin(plugin, "pytest_addoption", parser=self._config._parser)
self.call_plugin(plugin, "pytest_configure", config=self._config)
def call_plugin(self, plugin, methname, **kwargs):
return self.MultiCall(self.listattr(methname, plugins=[plugin]),
**kwargs).execute(firstresult=True)
def do_configure(self, config):
assert not hasattr(self, '_config')

View File

@ -172,12 +172,9 @@ class TestPytestPluginInteractions:
def test_configure(self, testdir):
config = testdir.parseconfig()
l = []
events = []
class A:
def pytest_configure(self, config):
l.append(self)
def xyz(self, obj):
events.append(obj)
config.pluginmanager.register(A())
assert len(l) == 0
@ -186,11 +183,7 @@ class TestPytestPluginInteractions:
config.pluginmanager.register(A()) # this should lead to a configured() plugin
assert len(l) == 2
assert l[0] != l[1]
config.pluginmanager.call_each("xyz", obj=42)
assert len(events) == 2
assert events == [42,42]
config.pluginmanager.do_unconfigure(config=config)
config.pluginmanager.register(A())
assert len(l) == 2
@ -209,16 +202,6 @@ class TestPytestPluginInteractions:
pluginmanager.register(My1())
assert pluginmanager.getfirst("x") == 1
def test_call_each(self):
pluginmanager = PluginManager()
class My:
def method(self, arg):
pass
pluginmanager.register(My())
py.test.raises(TypeError, 'pluginmanager.call_each("method")')
l = pluginmanager.call_each("method", arg=42)
assert l == []
py.test.raises(TypeError, 'pluginmanager.call_each("method", arg=42, s=13)')
def test_call_firstresult(self):
pluginmanager = PluginManager()