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

Method test_list_field_max_length

tests/fields/test_fields.py:1028–1042  ·  view source on GitHub ↗

Ensure ListField's max_length is respected.

(self)

Source from the content-addressed store, hash-verified

1026 e.save()
1027
1028 def test_list_field_max_length(self):
1029 """Ensure ListField's max_length is respected."""
1030
1031 class Foo(Document):
1032 items = ListField(IntField(), max_length=5)
1033
1034 foo = Foo()
1035 for i in range(1, 7):
1036 foo.items.append(i)
1037 if i < 6:
1038 foo.save()
1039 else:
1040 with pytest.raises(ValidationError) as exc_info:
1041 foo.save()
1042 assert "List is too long" in str(exc_info.value)
1043
1044 def test_list_field_max_length_set_operator(self):
1045 """Ensure ListField's max_length is respected for a "set" operator."""

Callers

nothing calls this directly

Calls 2

FooClass · 0.70
saveMethod · 0.45

Tested by

no test coverage detected