DSPy: The framework for programming—not prompting—language models
Python
Stabilize reasoning tests across LiteLLM dependency versions (#10655)
Isaac Miller869874767729
diff --git a/tests/predict/test_chain_of_thought.py b/tests/predict/test_chain_of_thought.pyindex a4b09a28b..44d18f6aa 100644--- a/tests/predict/test_chain_of_thought.py+++ b/tests/predict/test_chain_of_thought.py@@ -34,7 +34,11 @@ def test_chain_of_thought_with_native_reasoning():lm = dspy.LM(engine="litellm", model="anthropic/claude-3-7-sonnet-20250219", cache=False)dspy.settings.configure(lm=lm)- with mock.patch("litellm.completion") as mock_completion:+ # Match the mocked response's capability independently of LiteLLM's bundled model catalog.+ with (+ mock.patch("litellm.supports_reasoning", return_value=True),+ mock.patch("litellm.completion") as mock_completion,+ ):mock_completion.return_value = ModelResponse(choices=[Choices(diff --git a/tests/streaming/test_streaming.py b/tests/streaming/test_streaming.pyindex b3c86c8fb..210f1b33e 100644--- a/tests/streaming/test_streaming.py+++ b/tests/streaming/test_streaming.py@@ -2182,7 +2182,12 @@ async def test_default_cot_fallback_streams_reasoning(adapter_type, mode):dspy.ChainOfThought("question -> answer"),stream_listeners=[dspy.streaming.StreamListener("reasoning")],)- with mock.patch("litellm.acompletion", side_effect=stream), dspy.context(lm=lm, adapter=adapter_type()):+ # Keep supported-but-disabled cases distinct from models without native reasoning.+ with (+ mock.patch("litellm.supports_reasoning", return_value=mode != "unsupported"),+ mock.patch("litellm.acompletion", side_effect=stream),+ dspy.context(lm=lm, adapter=adapter_type()),+ ):values = [value async for value in program(question="Count items", config=config)]chunks = [value for value in values if isinstance(value, StreamResponse)]assert chunks and all(c.signature_field_name == "reasoning" for c in chunks)