MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / test_list_field_strict

Method test_list_field_strict

tests/fields/test_fields.py:1009–1026  ·  view source on GitHub ↗

Ensure that list field handles validation if provided a strict field type.

(self)

Source from the content-addressed store, hash-verified

1007 assert repr(foo.bars) == "[<Bar: Bar object>]"
1008
1009 def test_list_field_strict(self):
1010 """Ensure that list field handles validation if provided
1011 a strict field type.
1012 """
1013
1014 class Simple(Document):
1015 mapping = ListField(field=IntField())
1016
1017 Simple.drop_collection()
1018
1019 e = Simple()
1020 e.mapping = [1]
1021 e.save()
1022
1023 # try creating an invalid mapping
1024 with pytest.raises(ValidationError):
1025 e.mapping = ["abc"]
1026 e.save()
1027
1028 def test_list_field_max_length(self):
1029 """Ensure ListField's max_length is respected."""

Callers

nothing calls this directly

Calls 3

drop_collectionMethod · 0.80
SimpleClass · 0.70
saveMethod · 0.45

Tested by

no test coverage detected