coverage: ensure get_orientation is checked

This commit is contained in:
James R. Barlow
2018-11-02 01:32:20 -07:00
parent 3be02e1e8d
commit 77e87abe8f
+12 -1
View File
@@ -17,6 +17,7 @@
import logging
from io import BytesIO
from unittest.mock import Mock
from PIL import Image
import pytest
@@ -25,7 +26,7 @@ import pikepdf
from ocrmypdf import leptonica
from ocrmypdf.pdfinfo import PdfInfo
from ocrmypdf.exec import ghostscript
from ocrmypdf.exec import ghostscript, tesseract
from ocrmypdf.helpers import fspath
@@ -228,3 +229,13 @@ def test_rotate_page_level(image_angle, page_angle, resources, outdir):
assert p.returncode == 0, err
assert check_monochrome_correlation(outdir, reference, 1, out, 1) > 0.2
def test_tesseract_orientation(resources, tmpdir):
pix = leptonica.Pix.open(resources / 'crom.png')
pix_rotated = pix.rotate_orth(2) # 180 degrees clockwise
pix_rotated.write_implied_format(tmpdir / '000001.png')
log = Mock()
tesseract.get_orientation( # Test results of this are unreliable
tmpdir / '000001.png', engine_mode='3', timeout=10, log=log)