The choices parameter does not manage sets properly due to the use indexing (choices[0]).
def test_choices_allow_using_sets_as_choices(self):
"""Ensure that sets can be used when setting choices
"""
class Shirt(Document):
size = StringField(choices={'M', 'L'})
Shirt(size='M').validate()
File "/home/bgerard/dev/mongoengine/tests/fields/fields.py", line 3186
...
self = <mongoengine.fields.StringField object at 0x7ff8be807d50>, value = 'M'
def _validate_choices(self, value):
Document = _import_class('Document')
EmbeddedDocument = _import_class('EmbeddedDocument')
choice_list = self.choices
if isinstance(choice_list[0], (list, tuple)):
E TypeError: 'set' object does not support indexing