Fixed MultipleFileFieldTest.test_file_multiple_validation() test if Pillow isn't installed.

Follow up to fb4c55d9ec.
This commit is contained in:
Mariusz Felisiak 2023-05-04 08:09:02 +02:00 committed by GitHub
parent f5b39b77e3
commit fcfbf08abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import pickle
import unittest
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
@ -6,6 +7,13 @@ from django.core.validators import validate_image_file_extension
from django.forms import FileField, FileInput
from django.test import SimpleTestCase
try:
from PIL import Image # NOQA
except ImportError:
HAS_PILLOW = False
else:
HAS_PILLOW = True
class FileFieldTest(SimpleTestCase):
def test_filefield_1(self):
@ -151,6 +159,7 @@ class MultipleFileFieldTest(SimpleTestCase):
with self.assertRaisesMessage(ValidationError, msg):
f.clean(files[::-1])
@unittest.skipUnless(HAS_PILLOW, "Pillow not installed")
def test_file_multiple_validation(self):
f = MultipleFileField(validators=[validate_image_file_extension])