test_models.py 文件源码

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

项目:django-modeltrans 作者: zostera 项目源码 文件源码
def test_clean(self):
        '''
        Blog has required_languages=('nl', ), so this should raise an error
        if `title_nl` is not set.
        '''
        m = Blog(title='Horse', body='Horses are nice')

        with self.assertRaises(ValidationError) as e:
            m.full_clean()

        self.assertEquals(
            {(field, tuple(errors)) for field, errors in e.exception},
            {
                ('title_nl', ('This field cannot be null.', )),
                ('body_nl', ('This field cannot be null.', ))
            }
        )

        # With an added `title_nl`, it should validate.
        m.title_nl = 'Paard'
        m.body_nl = 'foo'
        m.full_clean()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号