Exemple #1
0
 def test_validate_list_proxy(self):
     field = ListField(IntField())
     orig = ListProxy(MockConfig(), field, [1, 2, 3])
     check = field._validate(MockConfig(),
                             ListProxy(MockConfig(), field, orig))
     assert isinstance(check, ListProxy)
     assert check == orig
     assert check is not orig
Exemple #2
0
 def test_required_empty(self):
     field = ListField(IntField(), required=True)
     with pytest.raises(ValueError):
         field._validate(MockConfig(), [])
Exemple #3
0
 def test_non_list(self):
     field = ListField(IntField())
     with pytest.raises(ValueError):
         field._validate(MockConfig(), 'asdf')
Exemple #4
0
 def test_required_not_empty(self):
     field = ListField(IntField(), required=True)
     value = field._validate(MockConfig(), [1, 2, '3'])
     assert value == [1, 2, 3]
     assert value.list_field is field
     assert value.item_field is field.field