def test_error_message(): schema = {"properties": {"foo": {"type": "integer"}}} instance = {"foo": None} try: validate(schema, instance) pytest.fail("Validation error should happen") except ValidationError as exc: assert (str(exc) == """null is not of type "integer" On instance["foo"]: null""")
def test_paths(): with pytest.raises(ValidationError) as exc: validate({"items": [{"type": "string"}]}, [1]) assert exc.value.schema_path == ["items", 0, "type"] assert exc.value.instance_path == [0] assert exc.value.message == '1 is not of type "string"'