feat: require offline PaddleOCR model assets

This commit is contained in:
2026-09-25 11:40:42 +08:00
parent 1dddceefc7
commit 1605ae6410
5 changed files with 34 additions and 5 deletions
+6 -1
View File
@@ -6,7 +6,7 @@ from docx import Document
from pptx import Presentation
from pptx.util import Inches
from wisegrade.parsing import parse_document
from wisegrade.parsing import _ocr_engine, parse_document
def test_pdf_pages_and_images(tmp_path):
@@ -20,6 +20,11 @@ def test_pdf_pages_and_images(tmp_path):
assert (tmp_path / "assets" / "page-1.png").exists()
def test_scanned_pdf_requires_offline_ocr_package(tmp_path):
with pytest.raises(RuntimeError, match="离线OCR模型目录"):
_ocr_engine(str(tmp_path / "missing-ocr"))
@pytest.mark.skipif(not shutil.which("libreoffice"), reason="LibreOffice is installed in the deployment image")
def test_docx_and_pptx_render(tmp_path):
word = Document()