def test_render_label_wrapped_right(self): field = fields.Radio(name='test') field.label_position = 'right' field_with_value_label = fields.Radio(name='test', label='My Radio', values=1) field_with_value_label.label_position = 'right' field_with_value = fields.Radio(name='test', values=(('Test', 1), )) field_with_value.label_position = 'right' field_with_multiple_values = fields.Radio(name='test', label='My Radio Group', values=(('Test', 1), ('Testing', 2))) field_with_multiple_values.label_position = 'right' assert str( field ) == '<label for="test"><input id="test" name="test" type="radio" />test</label>' assert str( field_with_value_label ) == '<label for="test"><input id="test" name="test" type="radio" value="1" />My Radio</label>' assert str( field_with_value ) == '<label for="test"><input id="test" name="test" type="radio" value="1" />Test</label>' assert str( field_with_multiple_values ) == '<label for="test_0"><input id="test_0" name="test" type="radio" value="1" />Test</label><label for="test_1"><input id="test_1" name="test" type="radio" value="2" />Testing</label>'
def test_render_with_wrapped_fieldset(self): field = fields.Radio(name='test', label='My Radio Group', values=(('Test', 1), ('Testing', 2))) single_field_value = fields.Radio(name='test', label='My Radio', values=1) assert field.render_with_label( ) == '<fieldset><legend>My Radio Group</legend><label for="test_0">Test<input id="test_0" name="test" type="radio" value="1" /></label><label for="test_1">Testing<input id="test_1" name="test" type="radio" value="2" /></label></fieldset>' assert single_field_value.render_with_label( ) == '<label for="test">My Radio<input id="test" name="test" type="radio" value="1" /></label>'
def test_render_label_without_wrapped(self): field = fields.Radio(name='test', label='My Radio Group', values=(('Test', 1), ('Testing', 2))) field.wrapped = False assert str( field ) == '<label for="test_0">Test</label><input id="test_0" name="test" type="radio" value="1" /><label for="test_1">Testing</label><input id="test_1" name="test" type="radio" value="2" />' field_right = fields.Radio(name='test', label='My Radio Group', values=(('Test', 1), ('Testing', 2))) field_right.wrapped = False field_right.label_position = 'right' assert str( field_right ) == '<input id="test_0" name="test" type="radio" value="1" /><label for="test_0">Test</label><input id="test_1" name="test" type="radio" value="2" /><label for="test_1">Testing</label>'
def test_checked_value(self): field = fields.Radio(name='test', label='My Radio Group', values=(('Test', 1), ('Testing', 2)), value=2) assert str( field ) == '<label for="test_0">Test<input id="test_0" name="test" type="radio" value="1" /></label><label for="test_1">Testing<input checked="checked" id="test_1" name="test" type="radio" value="2" /></label>'
def test_create(self): field = fields.Radio(name='test') assert field.value is None assert field.name == 'test'