Code

Ticket #10196: failing_tests.diff

File failing_tests.diff, 1.6 KB (added by vicvicvic, 5 years ago)

Theses tests show that the original patch does not fix the problem.

Line 
1diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
2index a202185..e39f618 100644
3--- a/tests/modeltests/model_forms/models.py
4+++ b/tests/modeltests/model_forms/models.py
5@@ -110,7 +110,9 @@ class ImageFile(models.Model):
6         # for PyPy, you need to check for the underlying modules
7         # If PIL is not available, this test is equivalent to TextFile above.
8         from PIL import Image, _imaging
9-        image = models.ImageField(storage=temp_storage, upload_to=custom_upload_path)
10+        image = models.ImageField(storage=temp_storage, upload_to=custom_upload_path, width_field="width", height_field="height")
11+        width = models.IntegerField(editable=False)
12+        height = models.IntegerField(editable=False)
13     except ImportError:
14         image = models.FileField(storage=temp_storage, upload_to=custom_upload_path)
15     path = models.CharField(max_length=16, blank=True, default='')
16@@ -1062,10 +1064,24 @@ True
17 True
18 >>> type(f.cleaned_data['image'])
19 <class 'django.core.files.uploadedfile.SimpleUploadedFile'>
20+
21+# FAIL:
22+# Will fail because ImageFile.width is null=False. Works
23+# if ImageFile.width is null=True
24 >>> instance = f.save()
25 >>> instance.image
26 <...FieldFile: tests/test.png>
27 
28+# Verify that the width_field was set properly
29+>>> instance.width
30+16
31+
32+# Verify that the width was committed to the database
33+# (Works if ImageFile.width is null=True)
34+>>> im = ImageFile.objects.get(pk=instance.pk)
35+>>> im.width
36+16
37+
38 # Delete the current file since this is not done by Django.
39 >>> instance.image.delete()
40