2015-08-31 02:13:42 +00:00
|
|
|
from django.forms import FileInput
|
|
|
|
|
|
|
|
from .base import WidgetTest
|
|
|
|
|
|
|
|
|
|
|
|
class FileInputTest(WidgetTest):
|
|
|
|
widget = FileInput()
|
|
|
|
|
|
|
|
def test_render(self):
|
|
|
|
"""
|
|
|
|
FileInput widgets never render the value attribute. The old value
|
|
|
|
isn't useful if a form is updated or an error occurred.
|
|
|
|
"""
|
|
|
|
self.check_html(self.widget, 'email', 'test@example.com', html='<input type="file" name="email" />')
|
|
|
|
self.check_html(self.widget, 'email', '', html='<input type="file" name="email" />')
|
|
|
|
self.check_html(self.widget, 'email', None, html='<input type="file" name="email" />')
|
2016-09-06 21:41:54 +00:00
|
|
|
|
|
|
|
def test_value_omitted_from_data(self):
|
|
|
|
self.assertIs(self.widget.value_omitted_from_data({}, {}, 'field'), True)
|
|
|
|
self.assertIs(self.widget.value_omitted_from_data({}, {'field': 'value'}, 'field'), False)
|