~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
"""Edge-case tests for BaseExporter._generate_safe_filename() and _prepend_title_if_needed().
Extends test_base_exporter.py with boundary conditions not covered:
all-special-char titles, exact 50-char boundary, all-whitespace titles,
and #NoSpace heading detection.
"""
class TestGenerateSafeFilenameEdgeCases:
"""Edge cases for _generate_safe_filename()."""
def _get_exporter(self):
from local_deep_research.exporters.latex_exporter import LaTeXExporter
return LaTeXExporter()
def test_all_special_chars_falls_back_to_default(self):
"""Title with only special chars sanitises to an empty stem → default."""
exporter = self._get_exporter()
result = exporter._generate_safe_filename("@#$%^&*()")
# Empty-after-sanitising falls back rather than emitting '.tex'
assert result == "research_report.tex"
def test_exactly_50_chars_preserved(self):
"""Title that is exactly 50 chars after cleaning should not be truncated."""
exporter = self._get_exporter()
title = "A" * 50
result = exporter._generate_safe_filename(title)
assert result == "A" * 50 + ".tex"
def test_51_chars_truncated_to_50(self):
"""Title 51 chars after cleaning should truncate to 50."""
exporter = self._get_exporter()
title = "A" * 51
result = exporter._generate_safe_filename(title)
name_part = result.replace(".tex", "")
assert len(name_part) == 50
def test_all_whitespace_title_falls_back_to_default(self):
"""Whitespace-only title is truthy but sanitises to an empty stem."""
exporter = self._get_exporter()
result = exporter._generate_safe_filename(" ")
# Empty-after-sanitising falls back rather than emitting '.tex'
assert result == "research_report.tex"
class TestPrependTitleEdgeCases:
"""Edge cases for _prepend_title_if_needed()."""
def _get_exporter(self):
from local_deep_research.exporters.latex_exporter import LaTeXExporter
return LaTeXExporter()
def test_hash_without_space_still_detected_as_heading(self):
"""Content starting with '#' (no space) is still treated as a heading."""
exporter = self._get_exporter()
result = exporter._prepend_title_if_needed("#NoSpace content", "Title")
# lstrip().startswith("#") → True → no prepend
assert result == "#NoSpace content"
def test_title_partial_match_no_prepend(self):
"""Content starting with '# Title' matches startswith check — no prepend."""
exporter = self._get_exporter()
# content.startswith("# Title") is True for "# Title Extra"
result = exporter._prepend_title_if_needed(
"# Title Extra\ncontent", "Title"
)
# "# Title Extra".startswith("# Title") → True → no prepend
assert result == "# Title Extra\ncontent"
def test_title_substring_mismatch(self):
"""Content heading that differs from title at start."""
exporter = self._get_exporter()
result = exporter._prepend_title_if_needed("# Other\ncontent", "Title")
# Doesn't start with "# Title", but starts with "#" → no prepend
assert result == "# Other\ncontent"
def test_content_with_only_newlines_gets_title(self):
"""Content of just newlines has no heading → title prepended."""
exporter = self._get_exporter()
result = exporter._prepend_title_if_needed("\n\n\n", "Title")
assert result == "# Title\n\n\n\n\n"