Commit f30b16a8 authored by Jerome Flesch's avatar Jerome Flesch

Merge branch 'verify-osd' into 'master'

Fix check that tesseract can detect orientation.

See merge request !117
parents 0ffeca80 9a2614eb
Pipeline #82655 failed with stage
in 14 minutes and 30 seconds
......@@ -37,7 +37,8 @@ __all__ = [
def can_detect_orientation():
return True
langs = get_available_languages()
return 'osd' in langs
def detect_orientation(image, lang=None):
......
......@@ -152,10 +152,11 @@ def _set_environment():
def can_detect_orientation():
version = get_version()
langs = get_available_languages()
return (
version[0] > 3 or
(version[0] == 3 and version[1] >= 3)
)
) and 'osd' in langs
def psm_parameter():
......
......@@ -41,8 +41,12 @@ class TestLibTesseract(BaseTest):
self.assertFalse(libtesseract.is_available())
libtess.TessVersion.assert_called_once_with()
def test_can_detect_orientation(self):
@patch("pyocr.libtesseract.get_available_languages")
def test_can_detect_orientation(self, get_available_languages):
get_available_languages.return_value = ['eng', 'fra', 'jpn', 'osd']
self.assertTrue(libtesseract.can_detect_orientation())
get_available_languages.return_value = ['eng', 'fra', 'jpn']
self.assertFalse(libtesseract.can_detect_orientation())
@patch("pyocr.libtesseract.tesseract_raw.g_libtesseract")
def test_version(self, libtess):
......
......@@ -176,11 +176,18 @@ class TestTesseract(BaseTest):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
@patch("pyocr.tesseract.get_available_languages")
@patch("pyocr.tesseract.get_version")
def test_can_detect_orientation_tesseract4(self, get_version):
def test_can_detect_orientation_tesseract4(self, get_version,
get_available_languages):
get_version.return_value = (4, 0, 0)
get_available_languages.return_value = ['eng', 'fra', 'jpn', 'osd']
self.assertTrue(tesseract.can_detect_orientation())
get_available_languages.return_value = ['eng', 'fra', 'jpn']
self.assertFalse(tesseract.can_detect_orientation())
@patch("pyocr.tesseract.get_version")
def test_can_detect_orientation_tesseract3(self, get_version):
get_version.return_value = (3, 3, 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment