test_serializers.py 文件源码

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

项目:django-chemtrails 作者: inonit 项目源码 文件源码
def test_serializer_non_existent_content_type(self):
        serializer = self.Serializer(data={'ctype': 'non.existent'})
        self.assertFalse(serializer.is_valid())
        self.assertTrue('ctype' in serializer.errors)

        try:
            serializer.is_valid(raise_exception=True)
            self.fail('Did not raise exception when serializing non-existent content '
                      'type string using using `raise_exception=True`')
        except serializers.ValidationError as e:
            self.assertEqual(str(e), "{'ctype': ['Invalid content type \"non.existent\" - object does not exist.']}")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号