mirror of
https://github.com/pydantic/pydantic-ai-harness.git
synced 2026-07-21 10:55:35 +00:00
Separate CodeMode print return cases
This commit is contained in:
@@ -128,10 +128,11 @@ result
|
||||
Avoid `print()` for return values as it produces Python string representations, not structured data. \
|
||||
Use `print()` only for supplementary logging or debug output.
|
||||
|
||||
Returns a non-`None` last expression's value directly. If `print()` was called, returns \
|
||||
`{"output": "<printed text>"}` without a non-`None` final expression and adds \
|
||||
`"result": <last expression>` for a plain, non-`None` final expression. Multimodal final expressions \
|
||||
remain top-level in a list alongside the printed text.\
|
||||
Returns a non-`None` last expression's value directly when nothing is printed. With `print()` output \
|
||||
and no non-`None` final expression, returns `{"output": "<printed text>"}`. With `print()` output and a \
|
||||
plain, non-`None` final expression, returns \
|
||||
`{"output": "<printed text>", "result": <last expression>}`. With `print()` output and a multimodal \
|
||||
final expression, returns a list with the printed text followed by the native content.\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -250,8 +250,9 @@ class TestCodeMode:
|
||||
assert 'Without a non-`None` final expression or print output, `run_code` returns `{}`.' in description
|
||||
assert 'A final expression that evaluates to `None` is treated as no result.' in description
|
||||
assert 'results = await asyncio.gather' not in description
|
||||
assert 'for a plain, non-`None` final expression' in description
|
||||
assert 'Multimodal final expressions remain top-level' in description
|
||||
assert 'With `print()` output and no non-`None` final expression' in description
|
||||
assert 'With `print()` output and a plain, non-`None` final expression' in description
|
||||
assert 'With `print()` output and a multimodal final expression' in description
|
||||
|
||||
async def test_run_code_function_examples_are_expressions(self) -> None:
|
||||
"""Async, sync, and mixed function examples do not end on assignments."""
|
||||
|
||||
Reference in New Issue
Block a user