test__api.py 文件源码

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

项目:guillotina 作者: plone 项目源码 文件源码
def test_named_hit(self):
        from zope.interface import Interface
        from zope.interface import implementer
        from guillotina.component import get_global_components
        class IFoo(Interface):
            pass
        class IBar(Interface):
            pass
        @implementer(IBar)
        class Bar(object):
            pass
        @implementer(IFoo)
        class Baz(object):
            def __init__(self, context):
                self.context = context
        get_global_components().registerAdapter(Baz, (IBar,), IFoo, 'named')
        bar = Bar()
        adapted = self._callFUT(bar, IFoo, 'named')
        self.assertTrue(adapted.__class__ is Baz)
        self.assertTrue(adapted.context is bar)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号