Django

Code

Ticket #10196: failing_tests.diff

File failing_tests.diff, 1.6 kB (added by vicvicvic, 1 year ago)

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

  • a/tests/modeltests/model_forms/models.py

    old new  
    110110        # for PyPy, you need to check for the underlying modules 
    111111        # If PIL is not available, this test is equivalent to TextFile above. 
    112112        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) 
    114116    except ImportError: 
    115117        image = models.FileField(storage=temp_storage, upload_to=custom_upload_path) 
    116118    path = models.CharField(max_length=16, blank=True, default='') 
     
    10621064True 
    10631065>>> type(f.cleaned_data['image']) 
    10641066<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 
    10651071>>> instance = f.save() 
    10661072>>> instance.image 
    10671073<...FieldFile: tests/test.png> 
    10681074 
     1075# Verify that the width_field was set properly 
     1076>>> instance.width 
     107716 
     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 
     108316 
     1084 
    10691085# Delete the current file since this is not done by Django. 
    10701086>>> instance.image.delete() 
    10711087