Fixed #21512 -- Added more complete information about Pillow and PIL in model_fields and model_forms tests.
This commit is contained in:
parent
c74504c2dd
commit
16d73d7416
|
@ -20,7 +20,7 @@ if Image:
|
||||||
PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile)
|
PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile)
|
||||||
from .models import temp_storage_dir
|
from .models import temp_storage_dir
|
||||||
else:
|
else:
|
||||||
# Pillow not available, create dummy classes (tests will be skipped anyway)
|
# Pillow/PIL not available, create dummy classes (tests will be skipped anyway)
|
||||||
class Person():
|
class Person():
|
||||||
pass
|
pass
|
||||||
PersonWithHeight = PersonWithHeightAndWidth = PersonDimensionsFirst = Person
|
PersonWithHeight = PersonWithHeightAndWidth = PersonDimensionsFirst = Person
|
||||||
|
@ -93,7 +93,7 @@ class ImageFieldTestMixin(object):
|
||||||
self.assertEqual(getattr(instance, height_field_name), height)
|
self.assertEqual(getattr(instance, height_field_name), height)
|
||||||
|
|
||||||
|
|
||||||
@skipIf(Image is None, "PIL is required to test ImageField")
|
@skipIf(Image is None, "Pillow/PIL is required to test ImageField")
|
||||||
class ImageFieldTests(ImageFieldTestMixin, TestCase):
|
class ImageFieldTests(ImageFieldTestMixin, TestCase):
|
||||||
"""
|
"""
|
||||||
Tests for ImageField that don't need to be run with each of the
|
Tests for ImageField that don't need to be run with each of the
|
||||||
|
@ -180,7 +180,7 @@ class ImageFieldTests(ImageFieldTestMixin, TestCase):
|
||||||
self.assertEqual(p.mugshot, loaded_p.mugshot)
|
self.assertEqual(p.mugshot, loaded_p.mugshot)
|
||||||
|
|
||||||
|
|
||||||
@skipIf(Image is None, "PIL is required to test ImageField")
|
@skipIf(Image is None, "Pillow/PIL is required to test ImageField")
|
||||||
class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
|
class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
|
||||||
"""
|
"""
|
||||||
Tests behavior of an ImageField and its dimensions fields.
|
Tests behavior of an ImageField and its dimensions fields.
|
||||||
|
@ -294,7 +294,7 @@ class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
|
||||||
self.assertEqual(p.mugshot.was_opened, True)
|
self.assertEqual(p.mugshot.was_opened, True)
|
||||||
|
|
||||||
|
|
||||||
@skipIf(Image is None, "PIL is required to test ImageField")
|
@skipIf(Image is None, "Pillow/PIL is required to test ImageField")
|
||||||
class ImageFieldNoDimensionsTests(ImageFieldTwoDimensionsTests):
|
class ImageFieldNoDimensionsTests(ImageFieldTwoDimensionsTests):
|
||||||
"""
|
"""
|
||||||
Tests behavior of an ImageField with no dimension fields.
|
Tests behavior of an ImageField with no dimension fields.
|
||||||
|
@ -303,7 +303,7 @@ class ImageFieldNoDimensionsTests(ImageFieldTwoDimensionsTests):
|
||||||
PersonModel = Person
|
PersonModel = Person
|
||||||
|
|
||||||
|
|
||||||
@skipIf(Image is None, "PIL is required to test ImageField")
|
@skipIf(Image is None, "Pillow/PIL is required to test ImageField")
|
||||||
class ImageFieldOneDimensionTests(ImageFieldTwoDimensionsTests):
|
class ImageFieldOneDimensionTests(ImageFieldTwoDimensionsTests):
|
||||||
"""
|
"""
|
||||||
Tests behavior of an ImageField with one dimensions field.
|
Tests behavior of an ImageField with one dimensions field.
|
||||||
|
@ -312,7 +312,7 @@ class ImageFieldOneDimensionTests(ImageFieldTwoDimensionsTests):
|
||||||
PersonModel = PersonWithHeight
|
PersonModel = PersonWithHeight
|
||||||
|
|
||||||
|
|
||||||
@skipIf(Image is None, "PIL is required to test ImageField")
|
@skipIf(Image is None, "Pillow/PIL is required to test ImageField")
|
||||||
class ImageFieldDimensionsFirstTests(ImageFieldTwoDimensionsTests):
|
class ImageFieldDimensionsFirstTests(ImageFieldTwoDimensionsTests):
|
||||||
"""
|
"""
|
||||||
Tests behavior of an ImageField where the dimensions fields are
|
Tests behavior of an ImageField where the dimensions fields are
|
||||||
|
@ -322,7 +322,7 @@ class ImageFieldDimensionsFirstTests(ImageFieldTwoDimensionsTests):
|
||||||
PersonModel = PersonDimensionsFirst
|
PersonModel = PersonDimensionsFirst
|
||||||
|
|
||||||
|
|
||||||
@skipIf(Image is None, "PIL is required to test ImageField")
|
@skipIf(Image is None, "Pillow/PIL is required to test ImageField")
|
||||||
class ImageFieldUsingFileTests(ImageFieldTwoDimensionsTests):
|
class ImageFieldUsingFileTests(ImageFieldTwoDimensionsTests):
|
||||||
"""
|
"""
|
||||||
Tests behavior of an ImageField when assigning it a File instance
|
Tests behavior of an ImageField when assigning it a File instance
|
||||||
|
@ -333,7 +333,7 @@ class ImageFieldUsingFileTests(ImageFieldTwoDimensionsTests):
|
||||||
File = File
|
File = File
|
||||||
|
|
||||||
|
|
||||||
@skipIf(Image is None, "PIL is required to test ImageField")
|
@skipIf(Image is None, "Pillow/PIL is required to test ImageField")
|
||||||
class TwoImageFieldTests(ImageFieldTestMixin, TestCase):
|
class TwoImageFieldTests(ImageFieldTestMixin, TestCase):
|
||||||
"""
|
"""
|
||||||
Tests a model with two ImageFields.
|
Tests a model with two ImageFields.
|
||||||
|
|
|
@ -1541,7 +1541,7 @@ class OldFormForXTests(TestCase):
|
||||||
self.assertEqual(bif.is_valid(), False)
|
self.assertEqual(bif.is_valid(), False)
|
||||||
self.assertEqual(bif.errors, {'biggie': ['Ensure this value is less than or equal to 9223372036854775807.']})
|
self.assertEqual(bif.errors, {'biggie': ['Ensure this value is less than or equal to 9223372036854775807.']})
|
||||||
|
|
||||||
@skipUnless(test_images, "PIL not installed")
|
@skipUnless(test_images, "Pillow/PIL not installed")
|
||||||
def test_image_field(self):
|
def test_image_field(self):
|
||||||
# ImageField and FileField are nearly identical, but they differ slighty when
|
# ImageField and FileField are nearly identical, but they differ slighty when
|
||||||
# it comes to validation. This specifically tests that #6302 is fixed for
|
# it comes to validation. This specifically tests that #6302 is fixed for
|
||||||
|
|
Loading…
Reference in New Issue