Update tests for can_detect_orientation in tesseract.

parent d6044e4e
...@@ -41,8 +41,12 @@ class TestLibTesseract(BaseTest): ...@@ -41,8 +41,12 @@ class TestLibTesseract(BaseTest):
self.assertFalse(libtesseract.is_available()) self.assertFalse(libtesseract.is_available())
libtess.TessVersion.assert_called_once_with() 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()) 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") @patch("pyocr.libtesseract.tesseract_raw.g_libtesseract")
def test_version(self, libtess): def test_version(self, libtess):
......
...@@ -176,11 +176,18 @@ class TestTesseract(BaseTest): ...@@ -176,11 +176,18 @@ class TestTesseract(BaseTest):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT stdout=subprocess.PIPE, stderr=subprocess.STDOUT
) )
@patch("pyocr.tesseract.get_available_languages")
@patch("pyocr.tesseract.get_version") @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_version.return_value = (4, 0, 0)
get_available_languages.return_value = ['eng', 'fra', 'jpn', 'osd']
self.assertTrue(tesseract.can_detect_orientation()) 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") @patch("pyocr.tesseract.get_version")
def test_can_detect_orientation_tesseract3(self, get_version): def test_can_detect_orientation_tesseract3(self, get_version):
get_version.return_value = (3, 3, 0) 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