Skip to content

Commit a5c1df8

Browse files
committed
fix: relax add_items mock assertions across Python versions
1 parent 7f6c482 commit a5c1df8

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

tests/test_agent_runner.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import warnings
77
from pathlib import Path
88
from typing import Any, Callable, cast
9-
from unittest.mock import ANY, call, patch
9+
from unittest.mock import patch
1010

1111
import httpx
1212
import pytest
@@ -3684,17 +3684,16 @@ async def echo_tool(text: str) -> str:
36843684
},
36853685
]
36863686

3687-
expected_calls = [
3688-
# First call is the initial input
3689-
call([expected_items[0]], wrapper=ANY),
3690-
# Second call is the first tool call and its result
3691-
call([expected_items[1], expected_items[2]], wrapper=ANY),
3692-
# Third call is the second tool call and its result
3693-
call([expected_items[3], expected_items[4]], wrapper=ANY),
3694-
# Fourth call is the final output
3695-
call([expected_items[5]], wrapper=ANY),
3687+
expected_item_batches = [
3688+
[expected_items[0]],
3689+
[expected_items[1], expected_items[2]],
3690+
[expected_items[3], expected_items[4]],
3691+
[expected_items[5]],
36963692
]
3697-
assert mock_add_items.call_args_list == expected_calls
3693+
assert len(mock_add_items.call_args_list) == len(expected_item_batches)
3694+
paired_calls = zip(mock_add_items.call_args_list, expected_item_batches)
3695+
for actual_call, expected_batch in paired_calls:
3696+
assert actual_call.args == (expected_batch,)
36983697
assert result.final_output == "Summary: Echoed foo and bar"
36993698
assert (await session.get_items()) == expected_items
37003699

0 commit comments

Comments
 (0)