Ticket #8196: 8196-r8425.diff

File 8196-r8425.diff, 2.3 KB (added by Marty Alchin, 16 years ago)

Replaces ImageFieldFile with ...FieldFile so it doesn't care whether it's an image or not

  • tests/modeltests/model_forms/models.py

     
    915915<class 'django.core.files.uploadedfile.SimpleUploadedFile'>
    916916>>> instance = f.save()
    917917>>> instance.image
    918 <ImageFieldFile: tests/test.png>
     918<...FieldFile: tests/test.png>
    919919
    920920# Delete the current file since this is not done by Django.
    921921>>> instance.image.delete()
     
    927927<class 'django.core.files.uploadedfile.SimpleUploadedFile'>
    928928>>> instance = f.save()
    929929>>> instance.image
    930 <ImageFieldFile: tests/test.png>
     930<...FieldFile: tests/test.png>
    931931
    932932# Edit an instance that already has the image defined in the model. This will not
    933933# save the image again, but leave it exactly as it is.
     
    936936>>> f.is_valid()
    937937True
    938938>>> f.cleaned_data['image']
    939 <ImageFieldFile: tests/test.png>
     939<...FieldFile: tests/test.png>
    940940>>> instance = f.save()
    941941>>> instance.image
    942 <ImageFieldFile: tests/test.png>
     942<...FieldFile: tests/test.png>
    943943
    944944# Delete the current image since this is not done by Django.
    945945
     
    952952True
    953953>>> instance = f.save()
    954954>>> instance.image
    955 <ImageFieldFile: tests/test2.png>
     955<...FieldFile: tests/test2.png>
    956956
    957957# Delete the current file since this is not done by Django.
    958958>>> instance.image.delete()
     
    963963True
    964964>>> instance = f.save()
    965965>>> instance.image
    966 <ImageFieldFile: tests/test2.png>
     966<...FieldFile: tests/test2.png>
    967967
    968968# Delete the current file since this is not done by Django.
    969969>>> instance.image.delete()
     
    977977True
    978978>>> instance = f.save()
    979979>>> instance.image
    980 <ImageFieldFile: None>
     980<...FieldFile: None>
    981981
    982982>>> f = ImageFileForm(data={'description': u'And a final one'}, files={'image': SimpleUploadedFile('test3.png', image_data)}, instance=instance)
    983983>>> f.is_valid()
    984984True
    985985>>> instance = f.save()
    986986>>> instance.image
    987 <ImageFieldFile: tests/test3.png>
     987<...FieldFile: tests/test3.png>
    988988
    989989# Delete the current file since this is not done by Django.
    990990>>> instance.image.delete()
     
    995995True
    996996>>> instance = f.save()
    997997>>> instance.image
    998 <ImageFieldFile: tests/test3.png>
     998<...FieldFile: tests/test3.png>
    999999>>> instance.delete()
    10001000
    10011001# Media on a ModelForm ########################################################
Back to Top