Skip to content

Commit 7d15cae

Browse files
committed
[chore][tests][place the new class beside the check it covers instead of the shared tail]
1 parent 5b166da commit 7d15cae

1 file changed

Lines changed: 38 additions & 38 deletions

File tree

tests/structs/test_agent.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,44 @@ def test_unknown_model_falls_back(self):
25122512
assert agent.context_length == 16000
25132513

25142514

2515+
# ============================================================================
2516+
# RELIABILITY CHECK WARNINGS
2517+
# ============================================================================
2518+
2519+
2520+
class TestFunctionCallingWarning:
2521+
"""The function-calling warning is for agents that actually have tools."""
2522+
2523+
@staticmethod
2524+
def _warnings_for(**kwargs):
2525+
with patch("swarms.structs.agent.LiteLLM"), patch(
2526+
"swarms.structs.agent.supports_function_calling",
2527+
return_value=False,
2528+
), patch("swarms.structs.agent.logger") as log:
2529+
Agent(
2530+
agent_name="warn_agent",
2531+
model_name="gpt-5.4",
2532+
max_loops=1,
2533+
print_on=False,
2534+
verbose=False,
2535+
persistent_memory=False,
2536+
**kwargs,
2537+
)
2538+
return " ".join(str(c) for c in log.warning.call_args_list)
2539+
2540+
def test_no_tools_no_function_calling_warning(self):
2541+
assert (
2542+
"does not support function calling"
2543+
not in self._warnings_for()
2544+
)
2545+
2546+
def test_with_tools_the_warning_still_fires(self):
2547+
warnings = self._warnings_for(
2548+
tools_list_dictionary=[{"function": {"name": "x"}}]
2549+
)
2550+
assert "does not support function calling" in warnings
2551+
2552+
25152553
# ============================================================================
25162554
# TOOLS LIST ISOLATION
25172555
# ============================================================================
@@ -2553,44 +2591,6 @@ def test_default_is_per_instance(self):
25532591
)
25542592

25552593

2556-
# ============================================================================
2557-
# RELIABILITY CHECK WARNINGS
2558-
# ============================================================================
2559-
2560-
2561-
class TestFunctionCallingWarning:
2562-
"""The function-calling warning is for agents that actually have tools."""
2563-
2564-
@staticmethod
2565-
def _warnings_for(**kwargs):
2566-
with patch("swarms.structs.agent.LiteLLM"), patch(
2567-
"swarms.structs.agent.supports_function_calling",
2568-
return_value=False,
2569-
), patch("swarms.structs.agent.logger") as log:
2570-
Agent(
2571-
agent_name="warn_agent",
2572-
model_name="gpt-5.4",
2573-
max_loops=1,
2574-
print_on=False,
2575-
verbose=False,
2576-
persistent_memory=False,
2577-
**kwargs,
2578-
)
2579-
return " ".join(str(c) for c in log.warning.call_args_list)
2580-
2581-
def test_no_tools_no_function_calling_warning(self):
2582-
assert (
2583-
"does not support function calling"
2584-
not in self._warnings_for()
2585-
)
2586-
2587-
def test_with_tools_the_warning_still_fires(self):
2588-
warnings = self._warnings_for(
2589-
tools_list_dictionary=[{"function": {"name": "x"}}]
2590-
)
2591-
assert "does not support function calling" in warnings
2592-
2593-
25942594
# ============================================================================
25952595
# MAIN TEST RUNNER
25962596
# ============================================================================

0 commit comments

Comments
 (0)