2016-09-06 21:41:54 +00:00
|
|
|
from django.forms import Widget
|
2017-01-07 00:11:32 +00:00
|
|
|
from django.forms.widgets import Input
|
2016-09-06 21:41:54 +00:00
|
|
|
|
2017-01-07 00:11:32 +00:00
|
|
|
from .base import WidgetTest
|
2016-09-06 21:41:54 +00:00
|
|
|
|
2017-01-07 00:11:32 +00:00
|
|
|
|
|
|
|
class WidgetTests(WidgetTest):
|
2016-09-06 21:41:54 +00:00
|
|
|
|
|
|
|
def test_value_omitted_from_data(self):
|
|
|
|
widget = Widget()
|
|
|
|
self.assertIs(widget.value_omitted_from_data({}, {}, 'field'), True)
|
|
|
|
self.assertIs(widget.value_omitted_from_data({'field': 'value'}, {}, 'field'), False)
|
2017-01-07 00:11:32 +00:00
|
|
|
|
|
|
|
def test_no_trailing_newline_in_attrs(self):
|
|
|
|
self.check_html(Input(), 'name', 'value', strict=True, html='<input type="None" name="name" value="value" />')
|
2017-01-22 18:15:56 +00:00
|
|
|
|
|
|
|
def test_attr_false_not_rendered(self):
|
|
|
|
html = '<input type="None" name="name" value="value" />'
|
|
|
|
self.check_html(Input(), 'name', 'value', html=html, attrs={'readonly': False})
|