def test_w_provides_w_adapts(self):
from zope.interface import Interface
from zope.interface import implementer
from guillotina.component.globalregistry import get_global_components
class IFoo(Interface):
pass
class IBar(Interface):
pass
@implementer(IFoo)
class Foo(object):
pass
class Bar(object):
def __init__(self, context):
self.context = context
self._callFUT(Bar, (IFoo,), IBar)
gsm = get_global_components()
foo = Foo()
adapted = gsm.subscribers((foo,), IBar)
self.assertEqual(len(adapted), 1)
self.assertTrue(isinstance(adapted[0], Bar))
self.assertTrue(adapted[0].context is foo)
评论列表
文章目录