Skip to content

Commit 2569f4a

Browse files
committed
refactor: clean up test examples
1 parent 8b5ce73 commit 2569f4a

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
@@ -669,10 +669,7 @@ async def my_tool(first: str, second: str) -> int:
669669
input_tokens=20,
670670
output_tokens=5,
671671
tool_calls=1,
672-
details={
673-
'input_tokens': 20,
674-
'output_tokens': 5,
675-
},
672+
details={'input_tokens': 20, 'output_tokens': 5},
676673
)
677674
)
678675
assert tool_called

tests/test_examples.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,6 @@ async def model_logic( # noqa: C901
628628
parts=[ToolCallPart(tool_name='final_result', args=args, tool_call_id='pyd_ai_tool_call_id')]
629629
)
630630
elif isinstance(m, ToolReturnPart) and m.tool_name == 'do_work':
631-
# Trigger a second tool call to cause tool_calls_limit to be exceeded in the docs example
632631
return ModelResponse(parts=[ToolCallPart(tool_name='do_work', args={}, tool_call_id='pyd_ai_tool_call_id')])
633632
elif isinstance(m, RetryPromptPart) and m.tool_name == 'calc_volume':
634633
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)