mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #32339 -- Added use_fieldset to Widget.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import copy
|
||||
import datetime
|
||||
|
||||
from django.forms import Select
|
||||
from django.forms import ChoiceField, Form, Select
|
||||
from django.test import override_settings
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
@@ -485,3 +485,20 @@ class SelectTest(WidgetTest):
|
||||
def test_doesnt_render_required_when_no_choices_are_available(self):
|
||||
widget = self.widget(choices=[])
|
||||
self.assertIs(widget.use_required_attribute(initial=None), False)
|
||||
|
||||
def test_fieldset(self):
|
||||
class TestForm(Form):
|
||||
template_name = "forms_tests/use_fieldset.html"
|
||||
field = ChoiceField(widget=self.widget, choices=self.beatles)
|
||||
|
||||
form = TestForm()
|
||||
self.assertIs(self.widget.use_fieldset, False)
|
||||
self.assertHTMLEqual(
|
||||
'<div><label for="id_field">Field:</label>'
|
||||
'<select name="field" id="id_field">'
|
||||
'<option value="J">John</option> '
|
||||
'<option value="P">Paul</option>'
|
||||
'<option value="G">George</option>'
|
||||
'<option value="R">Ringo</option></select></div>',
|
||||
form.render(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user