def test_many_selected_option(self, db, genres): field = HeavySelect2MultipleWidgetForm().fields["genres"] field.widget.choices = NUMBER_CHOICES widget_output = field.widget.render("genres", [1, 2]) selected_option = ( '<option value="{pk}" selected="selected">{value}</option>'.format( pk=1, value="One" ) ) selected_option_a = '<option value="{pk}" selected>{value}</option>'.format( pk=1, value="One" ) selected_option2 = ( '<option value="{pk}" selected="selected">{value}</option>'.format( pk=2, value="Two" ) ) selected_option2a = '<option value="{pk}" selected>{value}</option>'.format( pk=2, value="Two" ) assert ( selected_option in widget_output or selected_option_a in widget_output ), widget_output assert selected_option2 in widget_output or selected_option2a in widget_output
def test_many_selected_option(self, db, genres): field = HeavySelect2MultipleWidgetForm().fields['genres'] field.widget.choices = NUMBER_CHOICES widget_output = field.widget.render('genres', [1, 2]) selected_option = '<option value="{pk}" selected="selected">{value}</option>'.format(pk=1, value='One') selected_option2 = '<option value="{pk}" selected="selected">{value}</option>'.format(pk=2, value='Two') assert selected_option in widget_output, widget_output assert selected_option2 in widget_output