def test_additional_items_validate_failed(self): e = self.gen_class(self._type, items=[String(), Integer()], additional_items=String())() with pytest.raises(ValidationError) as exc_info: e.field = ["1", 1, 1] assert exc_info.value.args[0]["field"][2].code == "type"
def test_additional_items_validate_success(self): e = self.gen_class(self._type, items=[String(), Integer()], additional_items=Boolean())(field=["1", 1, "1"]) e.format(allow_coerce=True) assert e.field == ["1", 1, True]
def test_additional_items_success(self): e = self.gen_class(self._type, items=[String(), Integer()])() e.field = ["1", 1, None] assert e.field == ["1", 1, None]
def test_success_inner_type_many(self): e = self.gen_class(self._type, items=[String(), Integer()])() e.field = ["1", 1] assert e.field == ["1", 1]
def test_failed_inner_type_many(self): e = self.gen_class(self._type, items=[String(), Integer()])() with pytest.raises(ValidationError) as exc_info: e.field = [1, "1"] assert exc_info.value.args[0]["field"][0].code == "type" assert exc_info.value.args[0]["field"][1].code == "type"
def test_success_inner_type_one(self): e = self.gen_class(self._type, items=String())() e.field = ["1"] assert e.field == ["1"]
def test_failed_inner_type_one(self): e = self.gen_class(self._type, items=String())() with pytest.raises(ValidationError) as exc_info: e.field = [1] assert exc_info.value.args[0]["field"][0].code == "type"