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: replace 4 more tautological asserts with real contracts (#4249)

LearningCircuite3f1b19e0ad5
diff --git a/tests/content_fetcher/test_fetcher.py b/tests/content_fetcher/test_fetcher.py
index f89a626ee3..6ba110dbd3 100644
--- a/tests/content_fetcher/test_fetcher.py
+++ b/tests/content_fetcher/test_fetcher.py
@@ -66,12 +66,18 @@ class TestContentFetcherGetDownloader:
def test_get_arxiv_downloader(self):
"""Test arXiv downloader is returned."""
+ from local_deep_research.research_library.downloaders.arxiv import (
+ ArxivDownloader,
+ )
+
fetcher = ContentFetcher()
downloader = fetcher._get_downloader(URLType.ARXIV)
- # May be None if ArxivDownloader not available
- # but should not raise exception
- assert downloader is None or downloader is not None
+ # ArxivDownloader is bundled with the project dependencies, so
+ # it should always be available in CI; if a future refactor
+ # makes it optional, swap this for `is None or isinstance(...)`
+ # — but never `is None or is not None`, which asserts nothing.
+ assert isinstance(downloader, ArxivDownloader)
def test_downloader_caching(self):
"""Test downloaders are cached."""
diff --git a/tests/document_loaders/test_bytes_loader.py b/tests/document_loaders/test_bytes_loader.py
index 8050308b7f..79ec05465c 100644
--- a/tests/document_loaders/test_bytes_loader.py
+++ b/tests/document_loaders/test_bytes_loader.py
@@ -146,12 +146,12 @@ class TestExtractTextFromBytes:
assert result == "Hello!"
def test_extract_empty_content(self) -> None:
- """Test extracting from empty content."""
+ """Empty input must not crash and must return an empty string
+ (not None — None would signal extraction failure)."""
content = b""
result = extract_text_from_bytes(content, ".txt", "empty.txt")
- # Should return empty string or None, not crash
- assert result is not None or result is None
+ assert result == ""
def test_extract_unicode_content(self) -> None:
"""Test extracting unicode content."""
diff --git a/tests/news/test_headline_generator_extended.py b/tests/news/test_headline_generator_extended.py
index 93825c4676..9b3326fedf 100644
--- a/tests/news/test_headline_generator_extended.py
+++ b/tests/news/test_headline_generator_extended.py
@@ -115,7 +115,9 @@ class TestGenerateWithLLM:
assert callable(_generate_with_llm)
def test_calls_llm_with_findings(self):
- """Calls LLM when findings are provided."""
+ """When the LLM returns content, _generate_with_llm strips the
+ text and returns the resulting string (it does not return the
+ raw LangChain response object)."""
with patch(
"local_deep_research.config.llm_config.get_llm"
) as mock_get_llm:
@@ -129,7 +131,7 @@ class TestGenerateWithLLM:
result = _generate_with_llm("query", "Some findings", 100)
- assert result is not None or result is None # LLM may fail
+ assert result == "Test Headline"
def test_returns_none_on_llm_import_error(self):
"""Returns None when LLM import fails."""
diff --git a/tests/utilities/test_json_utils_edge_cases.py b/tests/utilities/test_json_utils_edge_cases.py
index 34b28d1669..e772c44054 100644
--- a/tests/utilities/test_json_utils_edge_cases.py
+++ b/tests/utilities/test_json_utils_edge_cases.py
@@ -156,17 +156,19 @@ class TestBracketExtractionEdgeCases:
"""Tests for _extract_by_brackets with prose around JSON."""
def test_closing_brace_in_prose_after_json(self):
- """rfind('}') finds the LAST brace, which may be in trailing prose."""
+ """When prose after the JSON contains stray braces, rfind('}')
+ latches onto the last brace (in the prose). The substring then
+ spans valid JSON plus trailing junk, which fails to parse —
+ so extract_json returns None. Pinning this behavior so a
+ future change cannot silently regress it."""
from local_deep_research.utilities.json_utils import extract_json
text = (
'Here is the result: {"answer": "yes"} and more text with } braces'
)
- # rfind("}") finds the last "}" which is in prose, not the JSON
result = extract_json(text)
- # The extraction still works because the substring includes valid JSON
- # but may also include junk — document the behaviour
- assert result is not None or result is None # either outcome is valid
+
+ assert result is None
def test_think_tags_wrapping_json(self):
"""JSON sandwiched between think tag blocks is extracted after tag removal."""