def test_multiwidget_field(self):
template = loader.get_template_from_string(u"""
{% load crispy_forms_tags %}
{% crispy form %}
""")
test_form = TestForm()
test_form.helper = FormHelper()
test_form.helper.layout = Layout(
MultiWidgetField(
'datetime_field',
attrs=(
{'rel': 'test_dateinput'},
{'rel': 'test_timeinput', 'style': 'width: 30px;', 'type': "hidden"}
)
)
)
c = Context({'form': test_form})
html = template.render(c)
self.assertEqual(html.count('class="dateinput'), 1)
self.assertEqual(html.count('rel="test_dateinput"'), 1)
self.assertEqual(html.count('rel="test_timeinput"'), 1)
self.assertEqual(html.count('style="width: 30px;"'), 1)
self.assertEqual(html.count('type="hidden"'), 1)
评论列表
文章目录