diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index a202185..e39f618 100644
a
|
b
|
class ImageFile(models.Model):
|
110 | 110 | # for PyPy, you need to check for the underlying modules |
111 | 111 | # If PIL is not available, this test is equivalent to TextFile above. |
112 | 112 | from PIL import Image, _imaging |
113 | | image = models.ImageField(storage=temp_storage, upload_to=custom_upload_path) |
| 113 | image = models.ImageField(storage=temp_storage, upload_to=custom_upload_path, width_field="width", height_field="height") |
| 114 | width = models.IntegerField(editable=False) |
| 115 | height = models.IntegerField(editable=False) |
114 | 116 | except ImportError: |
115 | 117 | image = models.FileField(storage=temp_storage, upload_to=custom_upload_path) |
116 | 118 | path = models.CharField(max_length=16, blank=True, default='') |
… |
… |
True
|
1062 | 1064 | True |
1063 | 1065 | >>> type(f.cleaned_data['image']) |
1064 | 1066 | <class 'django.core.files.uploadedfile.SimpleUploadedFile'> |
| 1067 | |
| 1068 | # FAIL: |
| 1069 | # Will fail because ImageFile.width is null=False. Works |
| 1070 | # if ImageFile.width is null=True |
1065 | 1071 | >>> instance = f.save() |
1066 | 1072 | >>> instance.image |
1067 | 1073 | <...FieldFile: tests/test.png> |
1068 | 1074 | |
| 1075 | # Verify that the width_field was set properly |
| 1076 | >>> instance.width |
| 1077 | 16 |
| 1078 | |
| 1079 | # Verify that the width was committed to the database |
| 1080 | # (Works if ImageFile.width is null=True) |
| 1081 | >>> im = ImageFile.objects.get(pk=instance.pk) |
| 1082 | >>> im.width |
| 1083 | 16 |
| 1084 | |
1069 | 1085 | # Delete the current file since this is not done by Django. |
1070 | 1086 | >>> instance.image.delete() |
1071 | 1087 | |