1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[1.11.x] Fixed #27866 -- Made ChoiceWidget.format_value() return a list

Thanks Tim Graham for the review.
Backport of e487ffd3f0 from master.
This commit is contained in:
Claude Paroz
2017-02-21 13:27:29 +01:00
parent ff0c6b83e5
commit 06d32f689e
2 changed files with 8 additions and 8 deletions

View File

@@ -7,6 +7,12 @@ class SelectMultipleTest(WidgetTest):
widget = SelectMultiple
numeric_choices = (('0', '0'), ('1', '1'), ('2', '2'), ('3', '3'), ('0', 'extra'))
def test_format_value(self):
widget = self.widget(choices=self.numeric_choices)
self.assertEqual(widget.format_value(None), [''])
self.assertEqual(widget.format_value(''), [''])
self.assertEqual(widget.format_value([3, 0, 1]), ['3', '0', '1'])
def test_render_selected(self):
self.check_html(self.widget(choices=self.beatles), 'beatles', ['J'], html=(
"""<select multiple="multiple" name="beatles">