8000 [4.1.x] Fixed MultipleFileFieldTest.test_file_multiple_validation() t… · django/django@0e5948b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e5948b

Browse files
committed
[4.1.x] Fixed MultipleFileFieldTest.test_file_multiple_validation() test if Pillow isn't installed.
Follow up to fb4c55d. Backport of fcfbf08 from main
1 parent 66e1e9b commit 0e5948b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/forms_tests/field_tests/test_filefield.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import pickle
2+
import unittest
23

34
from django.core.exceptions import ValidationError
45
from django.core.files.uploadedfile import SimpleUploadedFile
56
from django.core.validators import validate_image_file_extension
67
from django.forms import FileField, FileInput
78
from django.test import SimpleTestCase
89

10+
try:
11+
from PIL import Image # NOQA
12+
except ImportError:
13+
HAS_PILLOW = False
14+
else:
15+
HAS_PILLOW = True
16+
917

1018
class FileFieldTest(SimpleTestCase):
1119
def test_filefield_1(self):
@@ -151,6 +159,7 @@ def test_file_multiple_empty(self):
151159
with self.assertRaisesMessage(ValidationError, msg):
152160
f.clean(files[::-1])
153161

162+
@unittest.skipUnless(HAS_PILLOW, "Pillow not installed")
154163
def test_file_multiple_validation(self):
155164
f = MultipleFileField(validators=[validate_image_file_extension])
156165

0 commit comments

Comments
 (0)
0