Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,3 +961,33 @@ def __getattr__(self, attr: str) -> Item: ...
assert model.a.prop == 1
assert isinstance(model.a, Item)
assert model.other == "foo"


def test_function_call_output_accepts_string_and_list() -> None:
"""Regression test: FunctionCallOutput.output should accept both str and list."""
from openai.types.responses.response_input_item import FunctionCallOutput

# string output (original behavior)
m_str = construct_type(
type_=FunctionCallOutput,
value={
"call_id": "call_abc123",
"output": '{"result": 42}',
"type": "function_call_output",
},
)
assert isinstance(m_str, FunctionCallOutput)
assert m_str.output == '{"result": 42}'

# list output (expanded type per API docs)
m_list = construct_type(
type_=FunctionCallOutput,
value={
"call_id": "call_abc123",
"output": [{"type": "input_text", "text": "hello"}],
"type": "function_call_output",
},
)
assert isinstance(m_list, FunctionCallOutput)
assert isinstance(m_list.output, list)
assert len(m_list.output) == 1