Surface Tesseract config errors instead of FileNotFoundError
When Tesseract cannot find its 'hocr' or 'txt' config files in the tessdata configs/ directory, it prints "read_params_file: Can't open" warnings, exits 0, and produces no output. OCRmyPDF then crashed with a confusing FileNotFoundError on the missing hOCR file (issue #1687). Promote read_params_file warnings to TesseractConfigError with guidance on the likely cause, and verify the expected output file exists after Tesseract claims success as defense-in-depth for other silent-failure modes.
This commit is contained in:
@@ -128,7 +128,6 @@ def test_timeout(caplog):
|
||||
(b'Error in boxClipToRectangle', ''),
|
||||
(b'an unexpected error', 'an unexpected error'),
|
||||
(b'a dire warning', 'a dire warning'),
|
||||
(b'read_params_file something', 'read_params_file'),
|
||||
(b'an innocent message', 'innocent'),
|
||||
(b'\x7f\x7f\x80innocent unicode failure', 'innocent'),
|
||||
],
|
||||
@@ -148,6 +147,13 @@ def test_tesseract_log_output_raises(caplog):
|
||||
assert 'not found' in caplog.text
|
||||
|
||||
|
||||
def test_tesseract_log_output_raises_on_missing_config(caplog):
|
||||
with pytest.raises(tesseract.TesseractConfigError) as excinfo:
|
||||
tesseract.tesseract_log_output(b"read_params_file: Can't open hocr")
|
||||
assert 'hocr' in excinfo.value.args[0]
|
||||
assert 'read_params_file' in caplog.text
|
||||
|
||||
|
||||
def test_blocked_language(resources, no_outpdf):
|
||||
infile = resources / 'masks.pdf'
|
||||
for bad_lang in ['osd', 'equ']:
|
||||
|
||||
Reference in New Issue
Block a user