[svn r63917] remove now unused code
--HG-- branch : trunk
This commit is contained in:
parent
3015757b0a
commit
0b554bf925
|
@ -101,10 +101,6 @@ class Registry:
|
||||||
l.reverse()
|
l.reverse()
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def call_each(self, methname, *args, **kwargs):
|
|
||||||
""" return call object for executing a plugin call. """
|
|
||||||
return MultiCall(self.listattr(methname), *args, **kwargs).execute()
|
|
||||||
|
|
||||||
def call_firstresult(self, methname, *args, **kwargs):
|
def call_firstresult(self, methname, *args, **kwargs):
|
||||||
""" return first non-None result of a plugin method. """
|
""" return first non-None result of a plugin method. """
|
||||||
return MultiCall(self.listattr(methname), *args, **kwargs).execute(firstresult=True)
|
return MultiCall(self.listattr(methname), *args, **kwargs).execute(firstresult=True)
|
||||||
|
|
|
@ -97,29 +97,6 @@ class TestRegistry:
|
||||||
assert not registry.isregistered(my)
|
assert not registry.isregistered(my)
|
||||||
assert list(registry) == [my2]
|
assert list(registry) == [my2]
|
||||||
|
|
||||||
def test_call_methods(self):
|
|
||||||
plugins = Registry()
|
|
||||||
class api1:
|
|
||||||
def m(self, __call__, x):
|
|
||||||
return x
|
|
||||||
class api2:
|
|
||||||
def m(self, __call__, x, y=33):
|
|
||||||
return y
|
|
||||||
plugins.register(api1())
|
|
||||||
plugins.register(api2())
|
|
||||||
res = plugins.call_firstresult("m", x=5)
|
|
||||||
assert plugins.call_firstresult("notexist") is None
|
|
||||||
|
|
||||||
assert res == 33
|
|
||||||
reslist = plugins.call_each("m", x=5)
|
|
||||||
assert len(reslist) == 2
|
|
||||||
assert 5 in reslist
|
|
||||||
assert 33 in reslist
|
|
||||||
assert plugins.call_each("notexist") == []
|
|
||||||
|
|
||||||
assert plugins.call_plugin(api1(), 'm', x=12) == 12
|
|
||||||
assert plugins.call_plugin(api2(), 't') is None
|
|
||||||
|
|
||||||
def test_call_none_is_no_result(self):
|
def test_call_none_is_no_result(self):
|
||||||
plugins = Registry()
|
plugins = Registry()
|
||||||
class api1:
|
class api1:
|
||||||
|
@ -132,7 +109,6 @@ class TestRegistry:
|
||||||
plugins.register(api1())
|
plugins.register(api1())
|
||||||
plugins.register(api2())
|
plugins.register(api2())
|
||||||
assert plugins.call_firstresult('m') == 41
|
assert plugins.call_firstresult('m') == 41
|
||||||
assert plugins.call_each('m') == [41]
|
|
||||||
|
|
||||||
def test_call_noneasresult(self):
|
def test_call_noneasresult(self):
|
||||||
plugins = Registry()
|
plugins = Registry()
|
||||||
|
@ -142,7 +118,6 @@ class TestRegistry:
|
||||||
plugins.register(api1())
|
plugins.register(api1())
|
||||||
plugins.register(api1())
|
plugins.register(api1())
|
||||||
assert plugins.call_firstresult('m') is None
|
assert plugins.call_firstresult('m') is None
|
||||||
assert plugins.call_each('m') == [None, None]
|
|
||||||
|
|
||||||
def test_listattr(self):
|
def test_listattr(self):
|
||||||
plugins = Registry()
|
plugins = Registry()
|
||||||
|
|
Loading…
Reference in New Issue