from django.forms import RadioSelect from .base import WidgetTest class RadioSelectTest(WidgetTest): widget = RadioSelect() def test_render(self): self.check_html(self.widget, 'beatle', 'J', choices=self.beatles, html=( """""" )) def test_nested_choices(self): nested_choices = ( ('unknown', 'Unknown'), ('Audio', (('vinyl', 'Vinyl'), ('cd', 'CD'))), ('Video', (('vhs', 'VHS'), ('dvd', 'DVD'))), ) html = """ """ self.check_html( self.widget, 'nestchoice', 'dvd', choices=nested_choices, attrs={'id': 'media'}, html=html, ) def test_constructor_attrs(self): """ Attributes provided at instantiation are passed to the constituent inputs. """ widget = RadioSelect(attrs={'id': 'foo'}) html = """ """ self.check_html(widget, 'beatle', 'J', choices=self.beatles, html=html) def test_render_attrs(self): """ Attributes provided at render-time are passed to the constituent inputs. """ html = """ """ self.check_html(self.widget, 'beatle', 'J', choices=self.beatles, attrs={'id': 'bar'}, html=html)