Skip to content

Commit a73dda5

Browse files
committed
fixed
1 parent fe5719f commit a73dda5

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

tests/test_types.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,25 +246,30 @@ def test_nested_field() -> None:
246246
assert "validation errors for NestedField" in str(exc_info.value)
247247

248248

249-
def test_nested_field_type_as_str_unsupported() -> None:
249+
def test_nested_field_complex_type_as_str_unsupported() -> None:
250250
unsupported_types = ["list", "map", "struct"]
251251
for type_str in unsupported_types:
252252
with pytest.raises(ValueError) as exc_info:
253253
_ = NestedField(1, "field", type_str, required=True)
254254
assert f"Unsupported field type: '{type_str}'" in str(exc_info.value)
255255

256256

257-
@pytest.mark.parametrize("type_str, type_class", primitive_types.items())
258-
def test_nested_field_type_as_str(type_str: str, type_class: type) -> None:
259-
field_var = NestedField(
260-
1,
261-
"field",
262-
type_str,
263-
required=True,
264-
)
265-
assert isinstance(
266-
field_var.field_type, type_class
267-
), f"Expected {type_class.__name__}, got {field_var.field_type.__class__.__name__}"
257+
def test_nested_field_primitive_type_as_str() -> None:
258+
for type_str, type_class in primitive_types.items():
259+
field_var = NestedField(
260+
1,
261+
"field",
262+
type_str,
263+
required=True,
264+
)
265+
assert isinstance(
266+
field_var.field_type, type_class
267+
), f"Expected {type_class.__name__}, got {field_var.field_type.__class__.__name__}"
268+
269+
# Test that passing 'bool' raises a ValueError, as it should be 'boolean'
270+
with pytest.raises(ValueError) as exc_info:
271+
_ = NestedField(1, "field", "bool", required=True)
272+
assert "Unsupported field type: 'bool'" in str(exc_info.value)
268273

269274

270275
@pytest.mark.parametrize("input_index,input_type", non_parameterized_types)

0 commit comments

Comments
 (0)