summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-04 08:09:02 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-04 08:09:50 +0200
commit0e5948b8df5d25deb48a505cbf16f010d9dc603c (patch)
tree7098b71b59e605a03029a3424d24aeed3f36eb2f
parent66e1e9b006618ba00e804d18bd90d3a9e94801b3 (diff)
downloaddjango-stable/4.1.x.tar.gz
[4.1.x] Fixed MultipleFileFieldTest.test_file_multiple_validation() test if Pillow isn't installed.stable/4.1.x
Follow up to fb4c55d9ec4bb812a7fb91fa20510d91645e411b. Backport of fcfbf08abe3e6dc54894df6988024f055abc6c40 from main
-rw-r--r--tests/forms_tests/field_tests/test_filefield.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/forms_tests/field_tests/test_filefield.py b/tests/forms_tests/field_tests/test_filefield.py
index 00c74a7c1a..11388bdc09 100644
--- a/tests/forms_tests/field_tests/test_filefield.py
+++ b/tests/forms_tests/field_tests/test_filefield.py
@@ -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])