diff options
| author | Tim Graham <timograham@gmail.com> | 2015-09-23 09:24:14 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-09-23 10:26:19 -0400 |
| commit | 7cb3a488436e8e7d0249280e95ba2ee945c96c87 (patch) | |
| tree | 825256120b029107363fb59a5c705a4f995071da /tests/model_forms | |
| parent | 0e723ead5289f64d6fd648104c2aa741394060de (diff) | |
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.
Diffstat (limited to 'tests/model_forms')
| -rw-r--r-- | tests/model_forms/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
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']), + '<input id="id_myfile" name="myfile" type="file" />' + ) + def test_file_field_data(self): # Test conditions when files is either not given or empty. f = TextFileForm(data={'description': 'Assistance'}) |
