[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:
parent
ad06cfdc9d
commit
2d98dbfc81
|
@ -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.
|
||||
|
|
|
@ -49,6 +49,22 @@ class TestMultiCall:
|
|||
call = MultiCall([n, m])
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue