test(extract): reach extra-missing through the import probe
Both tests reached `extractor_extra_missing` through a `.docx`/`.xlsx` filename, which works only while `_UNPARSED_OPTIONAL_EXTENSIONS` is non-empty. Those types are about to gain a converter, which empties the set and makes the membership branch unreachable -- the tests would have gone red for the right reason at the worst moment, mid-series. Repointed both at the import probe, the mechanism the pdf gate already uses and the one path that stays reachable however many types gain parsers. Measured negative control: without the probe the same call raises `extractor_pdf_error`, so the probe is load-bearing and the test can still fail. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
11cde6d0b5
commit
5f524f3902
2 changed files with 26 additions and 9 deletions
|
|
@ -12,6 +12,7 @@ import hashlib
|
|||
import importlib.util
|
||||
import json
|
||||
import sqlite3
|
||||
import sys
|
||||
import urllib.error
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
|
@ -344,12 +345,14 @@ def test_extractor_unknown() -> None:
|
|||
assert code_of(excinfo) == "extractor_unknown"
|
||||
|
||||
|
||||
def test_extractor_extra_missing() -> None:
|
||||
# `docx` rather than `pdf`: the extra now ships a pdf parser, so the type
|
||||
# that still has none is what proves this code is reachable. The pdf
|
||||
# import-probe path is covered in tests/test_extract.py.
|
||||
def test_extractor_extra_missing(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
# The import probe rather than a suffix: `docx` proved this code reachable
|
||||
# only while the extra shipped no parser for it. Once it gains a converter,
|
||||
# `_UNPARSED_OPTIONAL_EXTENSIONS` empties and the membership branch becomes
|
||||
# unreachable — the probe is the path that survives.
|
||||
monkeypatch.setitem(sys.modules, "pdfplumber", None)
|
||||
with pytest.raises(ExtractionError) as excinfo:
|
||||
extract_text("doc.docx", b"binary")
|
||||
extract_text("report.pdf", b"%PDF-1.4")
|
||||
assert code_of(excinfo) == "extractor_extra_missing"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue