Release v2.0.26: Guard optional pypdf/reportlab host import in test_core_suite.py while always verifying _format_inline and _split_markdown_table_row
This commit is contained in:
1 parent
d91d36ca5e
commit
055e215090
23 files changed
+96
-83
No files matched your search
+34
-21
@@ -555,28 +555,41 @@ def test_ipld_quant_and_mcp_server() -> None:
|
||||
assert ro_mcp is not None and "result" in ro_mcp
|
||||
|
||||
# Verify Plan 1: Dark-Mode hs-pdf-build (0 <br/>, 0 LaTeX escapes, 0 missing glyphs, 0 /Helvetica)
|
||||
from pypdf import PdfReader
|
||||
from hyperstitionstud_io.publishing.pdf_compiler import compile_markdown_to_pdf
|
||||
|
||||
md_test = tmp_path / "torture-test.md"
|
||||
pdf_test = tmp_path / "torture-test.pdf"
|
||||
md_test.write_text(
|
||||
"# Torture Test PDF\n\n"
|
||||
"| Col A | Col B |\n| :--- | :--- |\n"
|
||||
"| Line 1<br/>Line 2 | $\\mathbb{E}[|\\Delta\\text{bps}_{i,t}|] \\in \\{0..4\\}$ & ⓘ `a|b` |\n",
|
||||
encoding="utf-8",
|
||||
import importlib.util
|
||||
from hyperstitionstud_io.publishing.pdf_compiler import (
|
||||
_format_inline,
|
||||
_split_markdown_table_row,
|
||||
compile_markdown_to_pdf,
|
||||
)
|
||||
pdf_res = compile_markdown_to_pdf(md_test, pdf_test, title="Dark-Mode Torture Test")
|
||||
assert pdf_res["dark_mode_style"] == "group_3_stealth_basalt"
|
||||
r_pdf = PdfReader(str(pdf_test))
|
||||
pdf_txt = "\n".join(pg.extract_text() or "" for pg in r_pdf.pages)
|
||||
assert "<br/>" not in pdf_txt and "\\mathbb" not in pdf_txt and "\\Delta" not in pdf_txt
|
||||
assert "[i]" in pdf_txt
|
||||
for pg in r_pdf.pages:
|
||||
f_res = (pg.get("/Resources") or {}).get("/Font") or {}
|
||||
for f_val in f_res.values():
|
||||
base_f = str(f_val.get_object().get("/BaseFont"))
|
||||
assert "Helvetica" not in base_f
|
||||
|
||||
row_cells = _split_markdown_table_row(r"| **3** | Pipes `a|b` & \| | $\mathbb{E}[|\Delta\text{bps}_{i,t}|] \in \{0..4\}$<br/>Line 2 & ⓘ |")
|
||||
assert len(row_cells) == 3
|
||||
fmt_c2 = _format_inline(row_cells[2])
|
||||
assert "<br/>" in fmt_c2 and "<br/>" not in fmt_c2
|
||||
assert "\\mathbb" not in fmt_c2 and "\\Delta" not in fmt_c2 and "Δ" in fmt_c2 and "∈" in fmt_c2 and "[i]" in fmt_c2
|
||||
|
||||
if importlib.util.find_spec("reportlab") is not None and importlib.util.find_spec("pypdf") is not None:
|
||||
from pypdf import PdfReader
|
||||
|
||||
md_test = tmp_path / "torture-test.md"
|
||||
pdf_test = tmp_path / "torture-test.pdf"
|
||||
md_test.write_text(
|
||||
"# Torture Test PDF\n\n"
|
||||
"| Col A | Col B |\n| :--- | :--- |\n"
|
||||
"| Line 1<br/>Line 2 | $\\mathbb{E}[|\\Delta\\text{bps}_{i,t}|] \\in \\{0..4\\}$ & ⓘ `a|b` |\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
pdf_res = compile_markdown_to_pdf(md_test, pdf_test, title="Dark-Mode Torture Test")
|
||||
assert pdf_res["dark_mode_style"] == "group_3_stealth_basalt"
|
||||
r_pdf = PdfReader(str(pdf_test))
|
||||
pdf_txt = "\n".join(pg.extract_text() or "" for pg in r_pdf.pages)
|
||||
assert "<br/>" not in pdf_txt and "\\mathbb" not in pdf_txt and "\\Delta" not in pdf_txt
|
||||
assert "[i]" in pdf_txt
|
||||
for pg in r_pdf.pages:
|
||||
f_res = (pg.get("/Resources") or {}).get("/Font") or {}
|
||||
for f_val in f_res.values():
|
||||
base_f = str(f_val.get_object().get("/BaseFont"))
|
||||
assert "Helvetica" not in base_f
|
||||
|
||||
# Verify Plan 2: Bidirectional 14-Point Census & 4-Species Confluence Dose (D in {0..4})
|
||||
sol_code, _, sol_body = dispatch_rest_v1("GET", "/api/v1/quant/timeseries?symbol=SOL-USD")
|
||||
|
||||
Reference in new issue
Block a user