[svn r62614] implementing __call__.exclude_other_results() to allow plugin hooks to

exclude results from other plugins.

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-05 23:35:35 +01:00
parent ad06cfdc9d
commit 2d98dbfc81
2 changed files with 22 additions and 0 deletions

View File

@ -52,6 +52,9 @@ class MultiCall:
res = self.currentmethod(self, *self.args, **self.kwargs)
else:
res = self.currentmethod(*self.args, **self.kwargs)
if hasattr(self, '_ex1'):
self.results = [res]
break
if res is not None:
if res is self.NONEASRESULT:
res = None
@ -63,6 +66,9 @@ class MultiCall:
if self.results:
return self.results[-1]
def exclude_other_results(self):
self._ex1 = True
class PyPlugins:
"""
Manage Plugins: Load plugins and manage calls to plugins.

View File

@ -50,6 +50,22 @@ class TestMultiCall:
res = call.execute(firstresult=True)
assert res == 2
def test_call_exclude_other_results(self):
def m(__call__):
__call__.exclude_other_results()
return 10
def n():
return 1
call = MultiCall([n, n, m, n])
res = call.execute()
assert res == [10]
# doesn't really make sense for firstresult-mode - because
# we might not have had a chance to run at all.
#res = call.execute(firstresult=True)
#assert res == 10
class TestPyPlugins:
def test_MultiCall(self):