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.

test(citations): fresh-interpreter guard that citation_formatter import stays light (#5036)

LearningCircuit1513c9ffe646
diff --git a/tests/content_fetcher/test_lazy_content_fetcher.py b/tests/content_fetcher/test_lazy_content_fetcher.py
index 8e6219991f..9749cb6db2 100644
--- a/tests/content_fetcher/test_lazy_content_fetcher.py
+++ b/tests/content_fetcher/test_lazy_content_fetcher.py
@@ -257,3 +257,40 @@ class TestHeavyDepsOnlyLoadWithContentFetcher:
assert after == "True", (
f"fetcher should be loaded after first access; after={after!r}"
)
+
+
+class TestCitationFormatterImportStaysLight:
+ """The payoff of #4992 for the citation formatter: with the package
+ init lazy, citation_formatter imports url_classifier normally (its
+ importlib disk-loader workaround is gone) and must stay cheap."""
+
+ def test_citation_formatter_import_pulls_no_heavy_deps(self):
+ heavy = _measure_heavy_imports(
+ "import local_deep_research.text_optimization.citation_formatter"
+ )
+ assert heavy == [], (
+ f"citation_formatter import pulled heavy deps: {heavy}"
+ )
+
+ def test_citation_formatter_import_does_not_load_fetcher(self):
+ script = textwrap.dedent(
+ """
+ import sys
+ import local_deep_research.text_optimization.citation_formatter
+ print("local_deep_research.content_fetcher.fetcher" in sys.modules)
+ """
+ )
+ result = subprocess.run(
+ [sys.executable, "-c", script],
+ capture_output=True,
+ text=True,
+ cwd=str(Path(__file__).resolve().parents[2]),
+ check=False,
+ )
+ assert result.returncode == 0, (
+ f"subprocess failed: stdout={result.stdout!r} "
+ f"stderr={result.stderr!r}"
+ )
+ assert result.stdout.strip() == "False", (
+ f"expected 'False', got {result.stdout.strip()!r}"
+ )