def test_error_strict(self): fields = { FieldName("version", alias="@version"): StringField(), FieldName("servers", alias="server"): [{ FieldName("type", alias="@type"): StringField(), "host": StringField(), "port": IntegerField() }] } serializer = SerializerFactory.create(None, fields, error_strict=False) raw_data = { "@version": "3.0", "server": { "id": "main", "@type": "main", "host": "127.0.0.1", "port": '80' } } load_data = serializer.load(raw_data) self.assertEqual(len(serializer.errors), 0) self.assertEqual( load_data, { "version": "3.0", "servers": [{ "type": "main", "host": "127.0.0.1", "port": 80 }] })
class SimpleTestConfig(BaseConfig): fields = { FieldName("version", alias="@version"): StringField(), FieldName("servers", alias="server"): [{ FieldName("type", alias="@type"): StringField(), "host": StringField(), "port": IntegerField() }] } loader_class = Mock()
class Config1(ReadWriteConfig): config_file = "a" loader_class = MemFileLoader.build(mem=mem) fields = { FieldName("version", alias="@version"): StringField(), }