Fix test suite so --clean is not requested when unpaper is not installed
This commit is contained in:
@@ -72,6 +72,17 @@ def needs_pdfminer(fn):
|
||||
return fn
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def have_unpaper():
|
||||
try:
|
||||
from ocrmypdf.exec import unpaper
|
||||
|
||||
unpaper.version()
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
TESTS_ROOT = os.path.abspath(os.path.dirname(__file__))
|
||||
SPOOF_PATH = os.path.join(TESTS_ROOT, 'spoof')
|
||||
PROJECT_ROOT = os.path.dirname(TESTS_ROOT)
|
||||
|
||||
+5
-7
@@ -28,7 +28,7 @@ import pytest
|
||||
from PIL import Image
|
||||
|
||||
from ocrmypdf.exceptions import ExitCode, MissingDependencyError
|
||||
from ocrmypdf.exec import ghostscript, qpdf, tesseract
|
||||
from ocrmypdf.exec import ghostscript, qpdf, tesseract, unpaper
|
||||
from ocrmypdf.leptonica import Pix
|
||||
from ocrmypdf.pdfa import file_claims_pdfa
|
||||
from ocrmypdf.pdfinfo import Colorspace, Encoding, PdfInfo
|
||||
@@ -164,7 +164,7 @@ def test_exotic_image(
|
||||
check_ocrmypdf(
|
||||
resources / pdf,
|
||||
outfile,
|
||||
'-dc',
|
||||
'-dc' if pytest.helpers.have_unpaper() else '-d',
|
||||
'-v',
|
||||
'1',
|
||||
'--output-type',
|
||||
@@ -282,8 +282,7 @@ def test_maximum_options(
|
||||
resources / 'multipage.pdf',
|
||||
outpdf,
|
||||
'-d',
|
||||
'-c',
|
||||
'-i',
|
||||
'-ci' if pytest.helpers.have_unpaper() else None,
|
||||
'-f',
|
||||
'-k',
|
||||
'--oversample',
|
||||
@@ -542,7 +541,6 @@ def test_jbig2_passthrough(spoof_tesseract_cache, resources, outpdf):
|
||||
'hocr',
|
||||
env=spoof_tesseract_cache,
|
||||
)
|
||||
|
||||
out_pageinfo = PdfInfo(out)
|
||||
assert out_pageinfo[0].images[0].enc == Encoding.jbig2
|
||||
|
||||
@@ -777,10 +775,10 @@ def test_pagesize_consistency(renderer, resources, outpdf):
|
||||
outpdf,
|
||||
'--pdf-renderer',
|
||||
renderer,
|
||||
'--clean',
|
||||
'--clean' if pytest.helpers.have_unpaper() else None,
|
||||
'--deskew',
|
||||
'--remove-background',
|
||||
'--clean-final',
|
||||
'--clean-final' if pytest.helpers.have_unpaper() else None,
|
||||
)
|
||||
|
||||
after_dims = first_page_dimensions(outpdf)
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ def test_pagesize_consistency_tess4(ensure_tess4, resources, outpdf):
|
||||
outpdf,
|
||||
'--pdf-renderer',
|
||||
'sandwich',
|
||||
'--clean',
|
||||
'--clean' if pytest.helpers.have_unpaper() else None,
|
||||
'--deskew',
|
||||
'--remove-background',
|
||||
'--clean-final',
|
||||
|
||||
@@ -15,20 +15,11 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from math import isclose
|
||||
from subprocess import DEVNULL, PIPE, Popen, check_call, check_output
|
||||
|
||||
import PyPDF2 as pypdf
|
||||
import pytest
|
||||
|
||||
from ocrmypdf import leptonica
|
||||
from ocrmypdf.exceptions import ExitCode
|
||||
from ocrmypdf.exec import ghostscript
|
||||
from ocrmypdf.pdfa import file_claims_pdfa
|
||||
from ocrmypdf.pdfinfo import Colorspace, Encoding, PdfInfo
|
||||
|
||||
check_ocrmypdf = pytest.helpers.check_ocrmypdf
|
||||
run_ocrmypdf = pytest.helpers.run_ocrmypdf
|
||||
|
||||
Reference in New Issue
Block a user