summaryrefslogtreecommitdiff
path: root/tests/model_forms/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/model_forms/tests.py')
-rw-r--r--tests/model_forms/tests.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 6520e54d06..e636d212d8 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -32,7 +32,7 @@ from .models import (
)
if test_images:
- from .models import ImageFile, OptionalImageFile
+ from .models import ImageFile, OptionalImageFile, NoExtensionImageFile
class ImageFileForm(forms.ModelForm):
class Meta:
@@ -44,6 +44,11 @@ if test_images:
model = OptionalImageFile
fields = '__all__'
+ class NoExtensionImageFileForm(forms.ModelForm):
+ class Meta:
+ model = NoExtensionImageFile
+ fields = '__all__'
+
class ProductForm(forms.ModelForm):
class Meta:
@@ -2461,6 +2466,19 @@ class FileAndImageFieldTests(TestCase):
self.assertEqual(instance.image.name, 'foo/test4.png')
instance.delete()
+ # Editing an instance that has an image without an extension shouldn't
+ # fail validation. First create:
+ f = NoExtensionImageFileForm(
+ data={'description': 'An image'},
+ files={'image': SimpleUploadedFile('test.png', image_data)},
+ )
+ self.assertTrue(f.is_valid())
+ instance = f.save()
+ self.assertEqual(instance.image.name, 'tests/no_extension')
+ # Then edit:
+ f = NoExtensionImageFileForm(data={'description': 'Edited image'}, instance=instance)
+ self.assertTrue(f.is_valid())
+
class ModelOtherFieldTests(SimpleTestCase):
def test_big_integer_field(self):