mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
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 5c412dd8a7
.
This commit is contained in:
parent
0e723ead52
commit
7cb3a48843
3 changed files with 13 additions and 27 deletions
|
@ -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'})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue