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.']}")
评论列表
文章目录