Files
VoiceStudio/tests/test_longform_pdf_errors.py
debpalash fc47cb40c2 fix: review findings on the #4372–#4389 batch
- insertionSlot: falls back when the next segment has no finite start, and
  rounds a custom threshold to milliseconds before comparing (#4389).
- New test modules resolve app code at test time (#4380, #4382, #4383).
2026-11-23 13:05:01 +05:30

24 lines
693 B
Python

"""PDF parser errors from lazy page-tree access."""
import pytest
def test_unreadable_pdf_page_tree_reports_import_error(monkeypatch):
import importlib
pdf_to_chapter_script = importlib.import_module("services.longform_import").pdf_to_chapter_script # resolved at test time
import pypdf
class BrokenPages:
def __len__(self):
raise pypdf.errors.PdfReadError("missing page tree")
class Reader:
is_encrypted = False
pages = BrokenPages()
monkeypatch.setattr(pypdf, "PdfReader", lambda _stream: Reader())
with pytest.raises(ValueError, match="not a valid PDF file: missing page tree"):
pdf_to_chapter_script(b"PDF")