Standardize tesseract.generate_hocr and _pdf parameters

This commit is contained in:
James R. Barlow
2020-05-14 03:23:25 -07:00
parent 12a2f78c4d
commit 41eb54cc0a
6 changed files with 29 additions and 31 deletions
-1
View File
@@ -241,7 +241,6 @@ def run_ocrmypdf_api(input_file, output_file, *args, env=None):
[str(input_file), str(output_file)]
+ [str(arg) for arg in args if arg is not None]
)
if env:
options.tesseract_env = env.copy()
options.tesseract_env['_OCRMYPDF_TEST_INFILE'] = os.fspath(input_file)
+1 -1
View File
@@ -233,7 +233,7 @@ def test_german(spoof_tesseract_cache, resources, outdir):
env=spoof_tesseract_cache,
)
except MissingDependencyError:
if 'deu' not in tesseract.languages():
if 'deu' not in tesseract.get_languages():
pytest.xfail(reason="tesseract-deu language pack not installed")
raise
+5 -5
View File
@@ -77,7 +77,7 @@ def test_no_languages(tmp_path):
env['TESSDATA_PREFIX'] = fspath(tmp_path)
with pytest.raises(MissingDependencyError):
tesseract.languages(tesseract_env=env)
tesseract.get_languages(tesseract_env=env)
def test_image_too_large_hocr(monkeypatch, resources, outdir):
@@ -88,8 +88,8 @@ def test_image_too_large_hocr(monkeypatch, resources, outdir):
tesseract.generate_hocr(
input_file=resources / 'crom.png',
output_hocr=outdir / 'out.hocr',
output_sidecar=outdir / 'out.txt',
language=['eng'],
output_text=outdir / 'out.txt',
languages=['eng'],
engine_mode=None,
tessconfig=[],
timeout=180.0,
@@ -107,10 +107,10 @@ def test_image_too_large_pdf(monkeypatch, resources, outdir):
monkeypatch.setattr(tesseract, 'run', dummy_run)
tesseract.generate_pdf(
input_image=resources / 'crom.png',
input_file=resources / 'crom.png',
output_pdf=outdir / 'pdf.pdf',
output_text=outdir / 'txt.txt',
language=['eng'],
languages=['eng'],
engine_mode=None,
tessconfig=[],
timeout=180.0,