From 7cb3a488436e8e7d0249280e95ba2ee945c96c87 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 23 Sep 2015 09:24:14 -0400 Subject: Fixed #25410 -- Fixed empty ClearableFileInput crash on Python 2. Reverted "Fixes #24727 -- Prevented ClearableFileInput from masking exceptions on Python 2" and added a regression test. This reverts commit 5c412dd8a724b263489c1bd7a2fea381460665d7. --- tests/model_forms/tests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/model_forms') diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 80dcf43be7..98b9c1ad52 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1885,6 +1885,19 @@ class FileAndImageFieldTests(TestCase): self.assertIn('something.txt', rendered) self.assertIn('myfile-clear', rendered) + def test_render_empty_file_field(self): + class DocumentForm(forms.ModelForm): + class Meta: + model = Document + fields = '__all__' + + doc = Document.objects.create() + form = DocumentForm(instance=doc) + self.assertEqual( + str(form['myfile']), + '' + ) + def test_file_field_data(self): # Test conditions when files is either not given or empty. f = TextFileForm(data={'description': 'Assistance'}) -- cgit v1.3