Loading tests/regressiontests/model_fields/imagefield.py +400 −388 Original line number Diff line number Diff line Loading @@ -6,15 +6,20 @@ import shutil from django.core.files import File from django.core.files.images import ImageFile from django.test import TestCase from django.utils.unittest import skipIf from .models import (Image, Person, PersonWithHeight, PersonWithHeightAndWidth, PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile) from .models import Image # If PIL available, do these tests. if Image: from .models import (Person, PersonWithHeight, PersonWithHeightAndWidth, PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile) from .models import temp_storage_dir else: # PIL not available, create dummy classes (tests will be skipped anyway) class Person(): pass PersonWithHeight = PersonWithHeightAndWidth = PersonDimensionsFirst = Person PersonTwoImages = Person class ImageFieldTestMixin(object): Loading Loading @@ -83,6 +88,7 @@ if Image: self.assertEqual(getattr(instance, height_field_name), height) @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldTests(ImageFieldTestMixin, TestCase): """ Tests for ImageField that don't need to be run with each of the Loading Loading @@ -169,6 +175,7 @@ if Image: self.assertEqual(p.mugshot, loaded_p.mugshot) @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase): """ Tests behavior of an ImageField and its dimensions fields. Loading Loading @@ -282,6 +289,7 @@ if Image: self.assertEqual(p.mugshot.was_opened, True) @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldNoDimensionsTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField with no dimension fields. Loading @@ -290,6 +298,7 @@ if Image: PersonModel = Person @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldOneDimensionTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField with one dimensions field. Loading @@ -298,6 +307,7 @@ if Image: PersonModel = PersonWithHeight @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldDimensionsFirstTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField where the dimensions fields are Loading @@ -307,6 +317,7 @@ if Image: PersonModel = PersonDimensionsFirst @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldUsingFileTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField when assigning it a File instance Loading @@ -317,6 +328,7 @@ if Image: File = File @skipIf(Image is None, "PIL is required to test ImageField") class TwoImageFieldTests(ImageFieldTestMixin, TestCase): """ Tests a model with two ImageFields. Loading tests/regressiontests/model_fields/tests.py +4 −6 Original line number Diff line number Diff line Loading @@ -13,8 +13,6 @@ from django.utils import unittest from .models import (Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel, Document, RenamedField) # If PIL available, do these tests. if Image: from .imagefield import (ImageFieldTests, ImageFieldTwoDimensionsTests, TwoImageFieldTests, ImageFieldNoDimensionsTests, ImageFieldOneDimensionTests, ImageFieldDimensionsFirstTests, Loading Loading
tests/regressiontests/model_fields/imagefield.py +400 −388 Original line number Diff line number Diff line Loading @@ -6,15 +6,20 @@ import shutil from django.core.files import File from django.core.files.images import ImageFile from django.test import TestCase from django.utils.unittest import skipIf from .models import (Image, Person, PersonWithHeight, PersonWithHeightAndWidth, PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile) from .models import Image # If PIL available, do these tests. if Image: from .models import (Person, PersonWithHeight, PersonWithHeightAndWidth, PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile) from .models import temp_storage_dir else: # PIL not available, create dummy classes (tests will be skipped anyway) class Person(): pass PersonWithHeight = PersonWithHeightAndWidth = PersonDimensionsFirst = Person PersonTwoImages = Person class ImageFieldTestMixin(object): Loading Loading @@ -83,6 +88,7 @@ if Image: self.assertEqual(getattr(instance, height_field_name), height) @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldTests(ImageFieldTestMixin, TestCase): """ Tests for ImageField that don't need to be run with each of the Loading Loading @@ -169,6 +175,7 @@ if Image: self.assertEqual(p.mugshot, loaded_p.mugshot) @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase): """ Tests behavior of an ImageField and its dimensions fields. Loading Loading @@ -282,6 +289,7 @@ if Image: self.assertEqual(p.mugshot.was_opened, True) @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldNoDimensionsTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField with no dimension fields. Loading @@ -290,6 +298,7 @@ if Image: PersonModel = Person @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldOneDimensionTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField with one dimensions field. Loading @@ -298,6 +307,7 @@ if Image: PersonModel = PersonWithHeight @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldDimensionsFirstTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField where the dimensions fields are Loading @@ -307,6 +317,7 @@ if Image: PersonModel = PersonDimensionsFirst @skipIf(Image is None, "PIL is required to test ImageField") class ImageFieldUsingFileTests(ImageFieldTwoDimensionsTests): """ Tests behavior of an ImageField when assigning it a File instance Loading @@ -317,6 +328,7 @@ if Image: File = File @skipIf(Image is None, "PIL is required to test ImageField") class TwoImageFieldTests(ImageFieldTestMixin, TestCase): """ Tests a model with two ImageFields. Loading
tests/regressiontests/model_fields/tests.py +4 −6 Original line number Diff line number Diff line Loading @@ -13,8 +13,6 @@ from django.utils import unittest from .models import (Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel, Document, RenamedField) # If PIL available, do these tests. if Image: from .imagefield import (ImageFieldTests, ImageFieldTwoDimensionsTests, TwoImageFieldTests, ImageFieldNoDimensionsTests, ImageFieldOneDimensionTests, ImageFieldDimensionsFirstTests, Loading