Fix the duplicate ListField max_length test (#2110)
This is a follow-up after #2107.
Not sure what happened here, but in
87194856ec
I committed a copy-paste of the same test instead of a test validating the
max_length behavior along with a "set" operator.
This commit is contained in:
parent
82f0eb1cbc
commit
609f50d261
@ -1026,20 +1026,15 @@ class FieldTest(MongoDBTestCase):
|
|||||||
foo.save()
|
foo.save()
|
||||||
self.assertIn("List is too long", str(cm.exception))
|
self.assertIn("List is too long", str(cm.exception))
|
||||||
|
|
||||||
def test_list_field_max_length(self):
|
def test_list_field_max_length_set_operator(self):
|
||||||
"""Ensure ListField's max_length is respected."""
|
"""Ensure ListField's max_length is respected for a "set" operator."""
|
||||||
|
|
||||||
class Foo(Document):
|
class Foo(Document):
|
||||||
items = ListField(IntField(), max_length=5)
|
items = ListField(IntField(), max_length=3)
|
||||||
|
|
||||||
foo = Foo()
|
foo = Foo.objects.create(items=[1, 2, 3])
|
||||||
for i in range(1, 7):
|
|
||||||
foo.items.append(i)
|
|
||||||
if i < 6:
|
|
||||||
foo.save()
|
|
||||||
else:
|
|
||||||
with self.assertRaises(ValidationError) as cm:
|
with self.assertRaises(ValidationError) as cm:
|
||||||
foo.save()
|
foo.modify(set__items=[1, 2, 3, 4])
|
||||||
self.assertIn("List is too long", str(cm.exception))
|
self.assertIn("List is too long", str(cm.exception))
|
||||||
|
|
||||||
def test_list_field_rejects_strings(self):
|
def test_list_field_rejects_strings(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user