summaryrefslogtreecommitdiff
path: root/tests/validators
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2016-07-02 14:42:15 +0200
committerBaptiste Mispelon <bmispelon@gmail.com>2016-07-02 15:46:16 +0200
commita9215b7c36bff232bcc9416309726290dc74a9e8 (patch)
tree4c8973191e9eeb1a67856cbd8b42bc19000383fa /tests/validators
parented1c15d8fbc17e60621ca56f67340987531e647d (diff)
Refs #21548 -- Skipped tests that rely on pillow when it's not installed
Diffstat (limited to 'tests/validators')
-rw-r--r--tests/validators/tests.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 56dea8804f..459324fb74 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -6,7 +6,7 @@ import os
import re
import types
from datetime import datetime, timedelta
-from unittest import TestCase
+from unittest import TestCase, skipUnless
from django.core.exceptions import ValidationError
from django.core.files.base import ContentFile
@@ -23,6 +23,13 @@ from django.test import SimpleTestCase
from django.test.utils import str_prefix
from django.utils._os import upath
+try:
+ from PIL import Image # noqa
+except ImportError:
+ PILLOW_IS_INSTALLED = False
+else:
+ PILLOW_IS_INSTALLED = True
+
NOW = datetime.now()
EXTENDED_SCHEMES = ['http', 'https', 'ftp', 'ftps', 'git', 'file', 'git+ssh']
@@ -299,6 +306,9 @@ def create_simple_test_method(validator, expected, value, num):
else:
val_name = validator.__class__.__name__
test_name = test_mask % (val_name, num)
+ if validator is validate_image_file_extension:
+ SKIP_MSG = "Pillow is required to test validate_image_file_extension"
+ test_func = skipUnless(PILLOW_IS_INSTALLED, SKIP_MSG)(test_func)
return test_name, test_func
# Dynamically assemble a test class with the contents of TEST_DATA