mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Tests & tweaks for ChoiceField
This commit is contained in:
parent
b5454dd022
commit
5a95baf2a2
|
@ -769,7 +769,9 @@ class MultipleChoiceField(ChoiceField):
|
||||||
])
|
])
|
||||||
|
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
return [self.choice_strings_to_values[str(item)] for item in value]
|
return set([
|
||||||
|
self.choice_strings_to_values[str(item)] for item in value
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
# File types...
|
# File types...
|
||||||
|
|
|
@ -577,7 +577,9 @@ class TestMultipleChoiceField(FieldValues):
|
||||||
'abc': ['Expected a list of items but got type `str`'],
|
'abc': ['Expected a list of items but got type `str`'],
|
||||||
('aircon', 'incorrect'): ['`incorrect` is not a valid choice.']
|
('aircon', 'incorrect'): ['`incorrect` is not a valid choice.']
|
||||||
}
|
}
|
||||||
outputs = {}
|
outputs = [
|
||||||
|
(['aircon', 'manual'], set(['aircon', 'manual']))
|
||||||
|
]
|
||||||
field = fields.MultipleChoiceField(
|
field = fields.MultipleChoiceField(
|
||||||
choices=[
|
choices=[
|
||||||
('aircon', 'AirCon'),
|
('aircon', 'AirCon'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user