def test_invalid_form_without_object_id(self):
"""
Checks whether the form without specified object id is invalid
"""
# open the image file
with open(self.image_path, 'rb') as upload_file:
# dict without object_id
post_dict = {
'position': 0,
'content_type': self.ctype.pk
}
# dict with valid uploaded file
file_dict = {
'image': SimpleUploadedFile(
upload_file.name,
upload_file.read()
)
}
# create a form with both dicts
form = forms.ImageAdminForm(post_dict, file_dict)
# check whether the form is not valid
self.assertFalse(form.is_valid())
评论列表
文章目录