Skip to content

Your lightweight open-source personal agent.

test(tools): verify nullable enum with multiple union types

Xubin Ren5e540434928c
diff --git a/tests/tools/test_tool_validation.py b/tests/tools/test_tool_validation.py
index 0c2da1653..0f8fac296 100644
--- a/tests/tools/test_tool_validation.py
+++ b/tests/tools/test_tool_validation.py
@@ -934,6 +934,7 @@ def test_null_only_schema_rejects_non_null_values(raw_type, value) -> None:
{"type": ["string", "null"], "enum": ["fast"]},
{"type": "string", "nullable": True, "enum": ["fast"]},
{"type": ["integer", "null"], "enum": [1]},
+ {"type": ["string", "integer", "null"], "enum": ["fast", 1]},
],
)
def test_nullable_schema_still_enforces_enum(schema) -> None:
@@ -941,6 +942,8 @@ def test_nullable_schema_still_enforces_enum(schema) -> None:
f"mode must be one of {schema['enum']}"
]
assert Schema.validate_json_schema_value(None, {**schema, "enum": [None]}) == []
+ for value in schema["enum"]:
+ assert Schema.validate_json_schema_value(value, schema) == []
def test_nullable_string_schema_enforces_enum() -> None: