Refactor out unpaper-specific tests

This commit is contained in:
James R. Barlow
2018-03-24 15:21:44 -07:00
parent 5b1c8541fc
commit e48590d66c
2 changed files with 62 additions and 21 deletions
-21
View File
@@ -124,11 +124,6 @@ def test_deskew(spoof_tesseract_noop, resources, outdir):
assert -0.5 < skew_angle < 0.5, "Deskewing failed"
def test_clean(spoof_tesseract_noop, resources, outpdf):
check_ocrmypdf(resources / 'skew.pdf', outpdf, '-c',
env=spoof_tesseract_noop)
def test_remove_background(spoof_tesseract_noop, resources, outdir):
from PIL import Image
@@ -551,22 +546,6 @@ def test_tesseract_image_too_big(renderer, spoof_tesseract_big_image_error,
env=spoof_tesseract_big_image_error)
@pytest.mark.skipif(True, reason="need new implementation")
def test_no_unpaper(resources, no_outpdf):
env = os.environ.copy()
env['OCRMYPDF_UNPAPER'] = os.path.abspath('./spoof/no_unpaper_here.py')
p, out, err = run_ocrmypdf(
resources / 'c02-22.pdf', no_outpdf, '--clean', env=env)
assert p.returncode == ExitCode.missing_dependency
def test_old_unpaper(spoof_unpaper_oldversion, resources, no_outpdf):
p, out, err = run_ocrmypdf(
resources / 'c02-22.pdf', no_outpdf, '--clean',
env=spoof_unpaper_oldversion)
assert p.returncode == ExitCode.missing_dependency
def test_algo4(resources, no_outpdf):
p, _, _ = run_ocrmypdf(resources / 'encrypted_algo4.pdf', no_outpdf)
assert p.returncode == ExitCode.encrypted_pdf
+62
View File
@@ -0,0 +1,62 @@
# © 2015-17 James R. Barlow: github.com/jbarlow83
#
# This file is part of OCRmyPDF.
#
# OCRmyPDF is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OCRmyPDF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from subprocess import Popen, PIPE, check_output, check_call, DEVNULL
from pathlib import Path
import os
import shutil
import resource
import pytest
from ocrmypdf.pdfinfo import PdfInfo, Colorspace, Encoding
import PyPDF2 as pypdf
from ocrmypdf.exceptions import ExitCode
from ocrmypdf import leptonica
from ocrmypdf.pdfa import file_claims_pdfa
from ocrmypdf.exec import ghostscript, tesseract, qpdf
import logging
from math import isclose
import PIL
# pytest.helpers is dynamic
# pylint: disable=no-member
# pylint: disable=w0612
check_ocrmypdf = pytest.helpers.check_ocrmypdf
run_ocrmypdf = pytest.helpers.run_ocrmypdf
spoof = pytest.helpers.spoof
@pytest.mark.skipif(True,
reason="needs new fixture implementation")
def test_no_unpaper(resources, no_outpdf):
# <disable unpaper here>
p, out, err = run_ocrmypdf(
resources / 'c02-22.pdf', no_outpdf, '--clean', env=env)
assert p.returncode == ExitCode.missing_dependency
def test_old_unpaper(spoof_unpaper_oldversion, resources, no_outpdf):
p, out, err = run_ocrmypdf(
resources / 'c02-22.pdf', no_outpdf, '--clean',
env=spoof_unpaper_oldversion)
assert p.returncode == ExitCode.missing_dependency
def test_clean(spoof_tesseract_noop, resources, outpdf):
check_ocrmypdf(resources / 'skew.pdf', outpdf, '-c',
env=spoof_tesseract_noop)