Commit 5bada99a authored by Jerome Flesch's avatar Jerome Flesch

Tests: tesseract: add a test regarding keeping Tesseract version in memory

Signed-off-by: Jerome Flesch's avatarJerome Flesch <jflesch@openpaper.work>
parent aabbbbab
......@@ -99,6 +99,23 @@ class TestTesseract(BaseTest):
popen.return_value = self.stdout
self.assertSequenceEqual(tesseract.get_version(), (4, 0, 0))
@patch("subprocess.Popen")
def test_version_cache(self, popen):
"""
Make sure Tesseract is not called everytime we need the version.
We need the version *often* in the code, and calling Tesseract
everytime wouldn't be wise.
"""
tesseract.g_version = None # drop cached version
self.stdout.stdout.read.return_value = self.message
popen.return_value = self.stdout
self.assertSequenceEqual(tesseract.get_version(), (4, 0, 0))
self.stdout.stdout.read.return_value = "garbage"
popen.return_value = self.stdout
self.assertSequenceEqual(tesseract.get_version(), (4, 0, 0))
@patch("subprocess.Popen")
def test_version_error_splitting(self, popen):
tesseract.g_version = None # drop cached version
......
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