Browse Source
✅ Fix coverage gap in serialize_sequence_value continue statement (#14933)
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: tiangolo <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
pull/14932/head
Copilot
5 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
4 additions and
1 deletions
-
tests/test_compat.py
|
|
@ -120,9 +120,12 @@ def test_serialize_sequence_value_with_optional_list_pipe_union(): |
|
|
|
|
|
|
|
|
def test_serialize_sequence_value_with_none_first_in_union(): |
|
|
def test_serialize_sequence_value_with_none_first_in_union(): |
|
|
"""Test that serialize_sequence_value handles Union[None, List[...]] correctly.""" |
|
|
"""Test that serialize_sequence_value handles Union[None, List[...]] correctly.""" |
|
|
|
|
|
from typing import Union |
|
|
|
|
|
|
|
|
from fastapi._compat import v2 |
|
|
from fastapi._compat import v2 |
|
|
|
|
|
|
|
|
field_info = FieldInfo(annotation=list[str] | None) |
|
|
# Use Union[None, list[str]] to ensure None comes first in the union args |
|
|
|
|
|
field_info = FieldInfo(annotation=Union[None, list[str]]) |
|
|
field = v2.ModelField(name="items", field_info=field_info) |
|
|
field = v2.ModelField(name="items", field_info=field_info) |
|
|
result = v2.serialize_sequence_value(field=field, value=["x", "y"]) |
|
|
result = v2.serialize_sequence_value(field=field, value=["x", "y"]) |
|
|
assert result == ["x", "y"] |
|
|
assert result == ["x", "y"] |
|
|
|