Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Correct mock patching in test_detailed_research_with_custom_llm (#668)

LearningCircuitc5988b81befc
diff --git a/tests/test_llm/test_api_llm_integration.py b/tests/test_llm/test_api_llm_integration.py
index 886f65af82..5d7e1aa354 100644
--- a/tests/test_llm/test_api_llm_integration.py
+++ b/tests/test_llm/test_api_llm_integration.py
@@ -141,21 +141,29 @@ def test_detailed_research_with_custom_llm(mock_search_system):
assert result["summary"] == "Mock research summary"
assert "findings" in result
- # Verify research context was set
- with patch(
- "local_deep_research.utilities.thread_context.set_search_context"
- ) as mock_context:
- detailed_research(
- query="Context test",
- llms={"ctx_llm": llm},
- provider="ctx_llm",
- research_id="ctx-123",
- )
+ # Verify research context was set - patch before calling the function
+ with (
+ patch(
+ "local_deep_research.api.research_functions._init_search_system"
+ ) as mock_init,
+ patch(
+ "local_deep_research.api.research_functions.set_search_context"
+ ) as mock_context,
+ ):
+ mock_init.return_value = mock_search_system
+
+ detailed_research(
+ query="Context test",
+ llms={"ctx_llm": llm},
+ provider="ctx_llm",
+ research_id="ctx-123",
+ )
- # Check context was set with correct research_id
- context_call = mock_context.call_args[0][0]
- assert context_call["research_id"] == "ctx-123"
- assert context_call["research_mode"] == "detailed"
+ # Check context was set with correct research_id
+ assert mock_context.called
+ context_call = mock_context.call_args[0][0]
+ assert context_call["research_id"] == "ctx-123"
+ assert context_call["research_mode"] == "detailed"
def test_generate_report_with_custom_llm():