Fixed #28242 -- Moved ImageField file extension validation to the form field.

This commit is contained in:
Manatsawin Hanmongkolchai 2017-05-28 14:05:21 +07:00 committed by Tim Graham
parent 6bb3b2bff4
commit a0c07d77fc
8 changed files with 47 additions and 11 deletions

View file

@ -2,7 +2,7 @@ import os
import shutil
from unittest import skipIf
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.exceptions import ImproperlyConfigured
from django.core.files import File
from django.core.files.images import ImageFile
from django.test import TestCase
@ -130,12 +130,6 @@ class ImageFieldTests(ImageFieldTestMixin, TestCase):
self.assertEqual(hash(p1_db.mugshot), hash(p1.mugshot))
self.assertIs(p1_db.mugshot != p1.mugshot, False)
def test_validation(self):
p = self.PersonModel(name="Joan")
p.mugshot.save("shot.txt", self.file1)
with self.assertRaisesMessage(ValidationError, "File extension 'txt' is not allowed."):
p.full_clean()
def test_instantiate_missing(self):
"""
If the underlying file is unavailable, still create instantiate the