import datetime
from django.forms import MultiWidget, RadioSelect
from django.test import override_settings
from .base import WidgetTest
class RadioSelectTest(WidgetTest):
widget = RadioSelect
def test_render(self):
choices = (('', '------'),) + self.beatles
self.check_html(self.widget(choices=choices), 'beatle', 'J', html="""
in the multiple_input.html widget template include the class
attribute.
"""
html = """
"""
self.check_html(self.widget(choices=self.beatles), 'beatle', 'J', attrs={'class': 'bar'}, html=html)
@override_settings(USE_THOUSAND_SEPARATOR=True)
def test_doesnt_localize_input_value(self):
choices = [
(1, 'One'),
(1000, 'One thousand'),
(1000000, 'One million'),
]
html = """
"""
self.check_html(self.widget(choices=choices), 'number', None, html=html)
choices = [
(datetime.time(0, 0), 'midnight'),
(datetime.time(12, 0), 'noon'),
]
html = """
"""
self.check_html(self.widget(choices=choices), 'time', None, html=html)
def test_render_as_subwidget(self):
"""A RadioSelect as a subwidget of MultiWidget."""
choices = (('', '------'),) + self.beatles
self.check_html(MultiWidget([self.widget(choices=choices)]), 'beatle', ['J'], html="""
""")