test_globalregistry.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:guillotina 作者: plone 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号