test_globalregistry.py 文件源码

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

项目:guillotina 作者: plone 项目源码 文件源码
def test_anonymous_no_provides_no_adapts(self):
        from zope.interface import Interface
        from zope.interface import implementer
        from guillotina.component.globalregistry import get_global_components
        from guillotina.component._declaration import adapter
        class IFoo(Interface):
            pass
        class IBar(Interface):
            pass
        @implementer(IFoo)
        class Foo(object):
            pass
        @adapter(IFoo)
        @implementer(IBar)
        class Bar(object):
            def __init__(self, context):
                self.context = context
        self._callFUT(Bar)
        gsm = get_global_components()
        foo = Foo()
        adapted = gsm.getAdapter(foo, IBar)
        self.assertTrue(isinstance(adapted, Bar))
        self.assertTrue(adapted.context is foo)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号