test__field.py 文件源码

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

项目:guillotina 作者: plone 项目源码 文件源码
def test__validate_source_is_ICSB_bound(self):
        from zope.interface import implementer
        from guillotina.schema.interfaces import IContextSourceBinder
        from guillotina.schema.exceptions import ConstraintNotSatisfied
        from guillotina.schema.tests.test_vocabulary import _makeSampleVocabulary

        @implementer(IContextSourceBinder)
        class SampleContextSourceBinder(object):
            def __call__(self, context):
                return _makeSampleVocabulary()

        s = SampleContextSourceBinder()
        choice = self._makeOne(source=s)
        # raises not iterable with unbound field
        self.assertRaises(TypeError, choice.validate, 1)
        o = object()
        clone = choice.bind(o)
        clone._validate(1)
        clone._validate(3)
        self.assertRaises(ConstraintNotSatisfied, clone._validate, 42)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号