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
def test_required_empty(self): field = ListField(IntField(), required=True) with pytest.raises(ValueError): field._validate(MockConfig(), [])
def test_non_list(self): field = ListField(IntField()) with pytest.raises(ValueError): field._validate(MockConfig(), 'asdf')
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