def test_dict_config_validation(self):
        class TestConf(schema.Schema):
            item = schema.DictItem(
                title="Poligon",
                description="Describe the Poligon",
                properties={"sides": schema.IntegerItem()},
            )

        try:
            jsonschema.validate({"item": {"sides": 1}}, TestConf.serialize())
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": {"sides": "1"}}, TestConf.serialize())
        self.assertIn("is not of type", excinfo.exception.message)

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": 2}, TestConf.serialize())
        self.assertIn("is not of type", excinfo.exception.message)

        class TestConf(schema.Schema):
            item = schema.DictItem(
                title="Poligon",
                description="Describe the Poligon",
                properties={"color": schema.StringItem(enum=["red", "green", "blue"])},
                pattern_properties={"si.*": schema.IntegerItem()},
            )

        try:
            jsonschema.validate(
                {"item": {"sides": 1, "color": "red"}}, TestConf.serialize()
            )
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate(
                {"item": {"sides": "4", "color": "blue"}}, TestConf.serialize()
            )
        self.assertIn("is not of type", excinfo.exception.message)

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": 2}, TestConf.serialize())
        self.assertIn("is not of type", excinfo.exception.message)

        class TestConf(schema.Schema):
            item = schema.DictItem(
                title="Poligon",
                description="Describe the Poligon",
                properties={"color": schema.StringItem(enum=["red", "green", "blue"])},
                pattern_properties={"si.*": schema.IntegerItem()},
                additional_properties=False,
            )

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate(
                {"item": {"color": "green", "sides": 4, "surfaces": 4}},
                TestConf.serialize(),
            )
        if JSONSCHEMA_VERSION < _LooseVersion("2.6.0"):
            self.assertIn(
                "Additional properties are not allowed", excinfo.exception.message
            )
        else:
            self.assertIn(
                "'surfaces' does not match any of the regexes",
                excinfo.exception.message,
            )

        class TestConf(schema.Schema):
            item = schema.DictItem(
                title="Poligon",
                description="Describe the Poligon",
                properties={"color": schema.StringItem(enum=["red", "green", "blue"])},
                additional_properties=schema.OneOfItem(
                    items=[schema.BooleanItem(), schema.IntegerItem()]
                ),
            )

        try:
            jsonschema.validate(
                {"item": {"sides": 1, "color": "red", "rugged_surface": False}},
                TestConf.serialize(),
            )
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate(
                {"item": {"sides": "4", "color": "blue"}}, TestConf.serialize()
            )
        if JSONSCHEMA_VERSION >= _LooseVersion("3.0.0"):
            self.assertIn("'4'", excinfo.exception.message)
            self.assertIn("is not of type", excinfo.exception.message)
            self.assertIn("'boolean'", excinfo.exception.message)
        else:
            self.assertIn(
                "is not valid under any of the given schemas", excinfo.exception.message
            )

        class TestConf(schema.Schema):
            item = schema.DictItem(
                title="Poligon",
                description="Describe the Poligon",
                properties={"color": schema.StringItem(enum=["red", "green", "blue"])},
                additional_properties=schema.OneOfItem(
                    items=[schema.BooleanItem(), schema.IntegerItem()]
                ),
                min_properties=2,
                max_properties=3,
            )

        try:
            jsonschema.validate(
                {"item": {"color": "red", "sides": 1}}, TestConf.serialize()
            )
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        try:
            jsonschema.validate(
                {"item": {"sides": 1, "color": "red", "rugged_surface": False}},
                TestConf.serialize(),
            )
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": {"color": "blue"}}, TestConf.serialize())
        self.assertIn("does not have enough properties", excinfo.exception.message)

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate(
                {
                    "item": {
                        "sides": 4,
                        "color": "blue",
                        "rugged_surface": False,
                        "opaque": True,
                    }
                },
                TestConf.serialize(),
            )
        self.assertIn("has too many properties", excinfo.exception.message)

        class TestConf(schema.Schema):
            item = schema.DictItem(
                title="Poligon",
                description="Describe the Poligon",
                properties={"sides": schema.IntegerItem(required=True)},
                additional_properties=schema.OneOfItem(
                    items=[schema.BooleanItem(), schema.StringItem()]
                ),
            )

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate(
                {"item": {"color": "blue", "rugged_surface": False, "opaque": True}},
                TestConf.serialize(),
            )
        self.assertIn("'sides' is a required property", excinfo.exception.message)

        class Props(schema.Schema):
            sides = schema.IntegerItem(required=True)

        class TestConf(schema.Schema):
            item = schema.DictItem(
                title="Poligon",
                description="Describe the Poligon",
                properties=Props(),
                additional_properties=schema.OneOfItem(
                    items=[schema.BooleanItem(), schema.StringItem()]
                ),
            )

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate(
                {"item": {"color": "blue", "rugged_surface": False, "opaque": True}},
                TestConf.serialize(),
            )
        self.assertIn("'sides' is a required property", excinfo.exception.message)