Skip to content

Commit 4f6a7b1

Browse files
authored
Improve OpenRouter test fragility (#2572)
1 parent a54ea66 commit 4f6a7b1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

integrations/openrouter/tests/test_openrouter_chat_generator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,12 @@ def test_live_run_with_tools_streaming(self, tools):
421421
assert tool_call.tool_name == "weather"
422422

423423
arguments = [tool_call.arguments for tool_call in tool_calls]
424-
assert sorted(arguments, key=lambda x: x["city"]) == [{"city": "Berlin"}, {"city": "Paris"}]
424+
# Extract city names and check they contain the expected cities
425+
# (LLM may return "Paris, France" or "Berlin, Germany" instead of just city names)
426+
cities = [arg["city"].lower() for arg in arguments]
427+
assert len(cities) == 2
428+
assert any("berlin" in city for city in cities), f"Expected 'berlin' in one of {cities}"
429+
assert any("paris" in city for city in cities), f"Expected 'paris' in one of {cities}"
425430
assert tool_message.meta["finish_reason"] == "tool_calls"
426431

427432
@pytest.mark.skipif(

0 commit comments

Comments
 (0)