Skip to content

Commit 81a4aab

Browse files
committed
refactor: clean up test examples
1 parent bbf7a25 commit 81a4aab

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

tests/models/test_anthropic.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,7 @@ async def my_tool(first: str, second: str) -> int:
668668
input_tokens=20,
669669
output_tokens=5,
670670
tool_calls=1,
671-
details={
672-
'input_tokens': 20,
673-
'output_tokens': 5,
674-
},
671+
details={'input_tokens': 20, 'output_tokens': 5},
675672
)
676673
)
677674
assert tool_called

tests/test_examples.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ async def model_logic( # noqa: C901
645645
parts=[ToolCallPart(tool_name='final_result', args=args, tool_call_id='pyd_ai_tool_call_id')]
646646
)
647647
elif isinstance(m, ToolReturnPart) and m.tool_name == 'do_work':
648-
# Trigger a second tool call to cause tool_calls_limit to be exceeded in the docs example
649648
return ModelResponse(parts=[ToolCallPart(tool_name='do_work', args={}, tool_call_id='pyd_ai_tool_call_id')])
650649
elif isinstance(m, RetryPromptPart) and m.tool_name == 'calc_volume':
651650
return ModelResponse(

tests/test_usage_limits.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,6 @@ async def ret_a(x: str) -> str:
253253
assert result.usage() == snapshot(RunUsage(requests=2, input_tokens=103, output_tokens=14, tool_calls=1))
254254

255255

256-
def test_deprecated_usage_limits():
257-
with warns(
258-
snapshot(['DeprecationWarning: `request_tokens_limit` is deprecated, use `input_tokens_limit` instead'])
259-
):
260-
assert UsageLimits(input_tokens_limit=100).request_tokens_limit == 100 # type: ignore
261-
262-
with warns(
263-
snapshot(['DeprecationWarning: `response_tokens_limit` is deprecated, use `output_tokens_limit` instead'])
264-
):
265-
assert UsageLimits(output_tokens_limit=100).response_tokens_limit == 100 # type: ignore
266-
267-
268256
async def test_output_tool_not_counted() -> None:
269257
"""Test that output tools are not counted in tool_calls usage metric."""
270258
test_agent = Agent(TestModel())
@@ -308,3 +296,15 @@ async def flaky_tool(x: str) -> str:
308296
# The tool was called twice (1 failure + 1 success), but only the successful call should be counted
309297
assert call_count == 2
310298
assert result.usage() == snapshot(RunUsage(requests=3, input_tokens=176, output_tokens=29, tool_calls=1))
299+
300+
301+
def test_deprecated_usage_limits():
302+
with warns(
303+
snapshot(['DeprecationWarning: `request_tokens_limit` is deprecated, use `input_tokens_limit` instead'])
304+
):
305+
assert UsageLimits(input_tokens_limit=100).request_tokens_limit == 100 # type: ignore
306+
307+
with warns(
308+
snapshot(['DeprecationWarning: `response_tokens_limit` is deprecated, use `output_tokens_limit` instead'])
309+
):
310+
assert UsageLimits(output_tokens_limit=100).response_tokens_limit == 100 # type: ignore

0 commit comments

Comments
 (0)