Files
wehub-resource-sync 7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

102 lines
3.9 KiB
Python

"""Edge-case tests for citation exporters — math mode, list EOF, BibTeX URL, and RIS unicode."""
class TestInlineMathPreservedBetweenDollars:
"""Verify content between $ markers is NOT escaped during LaTeX export."""
def test_inline_math_preserved_between_dollars(self):
"""$x^2 + y^2$ should keep ^ and + unescaped inside math mode."""
from local_deep_research.text_optimization.citation_formatter import (
LaTeXExporter,
)
exporter = LaTeXExporter()
content = "# Title\n\nThe formula $x^2 + y^2 = r^2$ is important."
result = exporter.export_to_latex(content)
# Math content between $ should be preserved (not escaped)
assert "$x^2 + y^2 = r^2$" in result
class TestDisplayMathDoubleDollarPreserved:
"""Verify $$...$$ display math blocks are preserved during LaTeX export."""
def test_display_math_double_dollar_preserved(self):
"""$$E = mc^2$$ should preserve the math content unescaped."""
from local_deep_research.text_optimization.citation_formatter import (
LaTeXExporter,
)
exporter = LaTeXExporter()
content = "# Title\n\n$$E = mc^2$$\n\nSome text."
result = exporter.export_to_latex(content)
# The display math content should be preserved
assert "E = mc^2" in result
# The ^ should NOT be escaped to \textasciicircum{} inside math
assert r"\textasciicircum" not in result
class TestListAtEndOfContentGetsClosingTag:
"""Verify list items at EOF trigger \\end{itemize} via _convert_lists lines 940-941."""
def test_list_at_end_of_content_gets_closing_tag(self):
"""List items at end of content (no trailing text) should get \\end{itemize}."""
from local_deep_research.text_optimization.citation_formatter import (
LaTeXExporter,
)
exporter = LaTeXExporter()
# Content ends with list items, no trailing non-list text
content = "# Title\n\nSome intro text.\n\n- Item one\n- Item two\n- Item three"
result = exporter.export_to_latex(content)
begin_count = result.count("\\begin{itemize}")
end_count = result.count("\\end{itemize}")
assert begin_count == end_count == 1
# The last \end{itemize} should be after the last \item
last_item_pos = result.rfind("\\item")
last_end_pos = result.rfind("\\end{itemize}")
assert last_end_pos > last_item_pos
class TestSourceWithoutUrlOmitsBibtexUrlField:
"""Verify BibTeX entry omits url= field when source has no URL."""
def test_source_without_url_omits_bibtex_url_field(self):
"""[1] Title without URL line → BibTeX entry should not contain url = {...}."""
from local_deep_research.text_optimization.citation_formatter import (
QuartoExporter,
)
exporter = QuartoExporter()
# Source without URL line
content = "# Report\n\nSome text [1].\n\n## Sources\n[1] A Book Title Without URL"
bib_content = exporter._generate_bibliography(content)
assert "ref1" in bib_content
assert "A Book Title Without URL" in bib_content
# Should NOT have url field since no URL was provided
assert "url = " not in bib_content
assert "howpublished" not in bib_content
class TestRisExporterHandlesUnicodeTitle:
"""Verify RIS exporter preserves Unicode characters in TI field."""
def test_ris_exporter_handles_unicode_title(self):
"""Unicode title '日本語' in RIS TI field should be preserved."""
from local_deep_research.text_optimization.citation_formatter import (
RISExporter,
)
exporter = RISExporter()
content = (
"## Sources\n[1] 日本語の研究論文\n URL: https://example.jp/paper"
)
ris = exporter.export_to_ris(content)
assert "TI - " in ris
assert "日本語" in ris
assert "UR - https://example.jp/paper" in ris