2023-06-02 02:47:41 -07:00
|
|
|
# SPDX-FileCopyrightText: 2023 James R. Barlow
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
2023-06-02 02:47:41 -07:00
|
|
|
import os
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2023-06-02 02:47:41 -07:00
|
|
|
from ocrmypdf.exceptions import ExitCode
|
|
|
|
|
2023-10-15 23:41:35 -07:00
|
|
|
from .conftest import run_ocrmypdf_api
|
2023-06-02 02:47:41 -07:00
|
|
|
|
|
|
|
|
|
|
|
def test_raster_continue_on_soft_error(resources, outpdf):
|
2023-10-15 23:41:35 -07:00
|
|
|
exitcode = run_ocrmypdf_api(
|
2023-06-02 02:47:41 -07:00
|
|
|
resources / 'francais.pdf',
|
|
|
|
outpdf,
|
|
|
|
'--continue-on-soft-render-error',
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/tesseract_noop.py',
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/gs_raster_soft_error.py',
|
|
|
|
)
|
2023-10-15 23:41:35 -07:00
|
|
|
assert exitcode == ExitCode.ok
|
2023-06-02 02:47:41 -07:00
|
|
|
|
|
|
|
|
|
|
|
def test_raster_stop_on_soft_error(resources, outpdf):
|
2023-10-15 23:41:35 -07:00
|
|
|
exitcode = run_ocrmypdf_api(
|
2023-06-02 02:47:41 -07:00
|
|
|
resources / 'francais.pdf',
|
|
|
|
outpdf,
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/tesseract_noop.py',
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/gs_raster_soft_error.py',
|
|
|
|
)
|
2023-10-15 23:41:35 -07:00
|
|
|
assert exitcode == ExitCode.child_process_error
|
2023-06-02 02:47:41 -07:00
|
|
|
|
|
|
|
|
|
|
|
def test_render_continue_on_soft_error(resources, outpdf):
|
2023-10-15 23:41:35 -07:00
|
|
|
exitcode = run_ocrmypdf_api(
|
2023-06-02 02:47:41 -07:00
|
|
|
resources / 'francais.pdf',
|
|
|
|
outpdf,
|
|
|
|
'--continue-on-soft-render-error',
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/tesseract_noop.py',
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/gs_render_soft_error.py',
|
|
|
|
)
|
2023-10-15 23:41:35 -07:00
|
|
|
assert exitcode == ExitCode.ok
|
2023-06-02 02:47:41 -07:00
|
|
|
|
|
|
|
|
2023-06-02 02:47:41 -07:00
|
|
|
@pytest.mark.skipif(os.name == 'nt', reason='Ghostscript on Windows errors out')
|
2023-06-02 02:47:41 -07:00
|
|
|
def test_render_stop_on_soft_error(resources, outpdf):
|
2023-10-15 23:41:35 -07:00
|
|
|
exitcode = run_ocrmypdf_api(
|
2023-06-02 02:47:41 -07:00
|
|
|
resources / 'francais.pdf',
|
|
|
|
outpdf,
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/tesseract_noop.py',
|
|
|
|
'--plugin',
|
|
|
|
'tests/plugins/gs_render_soft_error.py',
|
|
|
|
)
|
2023-10-15 23:41:35 -07:00
|
|
|
assert exitcode == ExitCode.child_process_error
|