diff mbox series

[3/6] tests/acceptance: Extract tesseract_available() helper in new namespace

Message ID 20201021105035.2477784-4-f4bug@amsat.org
State Accepted
Commit 162127f29f2a5a628ecea79d4718d3a51b1bffac
Headers show
Series tests/acceptance: Test the Fuloong 2E machine | expand

Commit Message

Philippe Mathieu-Daudé Oct. 21, 2020, 10:50 a.m. UTC
We are going to reuse tesseract_available(). Extract it to
a new 'tesseract_utils' namespace.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/machine_m68k_nextcube.py | 25 +++-----------------
 tests/acceptance/tesseract_utils.py       | 28 +++++++++++++++++++++++
 2 files changed, 31 insertions(+), 22 deletions(-)
 create mode 100644 tests/acceptance/tesseract_utils.py

Comments

Thomas Huth Oct. 24, 2020, 6:31 a.m. UTC | #1
On 21/10/2020 12.50, Philippe Mathieu-Daudé wrote:
> We are going to reuse tesseract_available(). Extract it to

> a new 'tesseract_utils' namespace.

> 

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---

>  tests/acceptance/machine_m68k_nextcube.py | 25 +++-----------------

>  tests/acceptance/tesseract_utils.py       | 28 +++++++++++++++++++++++

>  2 files changed, 31 insertions(+), 22 deletions(-)

>  create mode 100644 tests/acceptance/tesseract_utils.py


Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/tests/acceptance/machine_m68k_nextcube.py b/tests/acceptance/machine_m68k_nextcube.py
index 2baba5fdc26..3c7400c43e4 100644
--- a/tests/acceptance/machine_m68k_nextcube.py
+++ b/tests/acceptance/machine_m68k_nextcube.py
@@ -1,19 +1,19 @@ 
 # Functional test that boots a VM and run OCR on the framebuffer
 #
-# Copyright (c) Philippe Mathieu-Daudé <f4bug@amsat.org>
+# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
 #
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
 import os
-import re
 import time
 import logging
 
 from avocado_qemu import Test
 from avocado import skipUnless
 from avocado.utils import process
-from avocado.utils.path import find_command, CmdNotFoundError
+
+from tesseract_utils import tesseract_available
 
 PIL_AVAILABLE = True
 try:
@@ -22,25 +22,6 @@ 
     PIL_AVAILABLE = False
 
 
-def tesseract_available(expected_version):
-    try:
-        find_command('tesseract')
-    except CmdNotFoundError:
-        return False
-    res = process.run('tesseract --version')
-    try:
-        version = res.stdout_text.split()[1]
-    except IndexError:
-        version = res.stderr_text.split()[1]
-    return int(version.split('.')[0]) == expected_version
-
-    match = re.match(r'tesseract\s(\d)', res)
-    if match is None:
-        return False
-    # now this is guaranteed to be a digit
-    return int(match.groups()[0]) == expected_version
-
-
 class NextCubeMachine(Test):
     """
     :avocado: tags=arch:m68k
diff --git a/tests/acceptance/tesseract_utils.py b/tests/acceptance/tesseract_utils.py
new file mode 100644
index 00000000000..acd6e8c2faa
--- /dev/null
+++ b/tests/acceptance/tesseract_utils.py
@@ -0,0 +1,28 @@ 
+# ...
+#
+# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import re
+
+from avocado.utils.path import find_command, CmdNotFoundError
+
+def tesseract_available(expected_version):
+    try:
+        find_command('tesseract')
+    except CmdNotFoundError:
+        return False
+    res = process.run('tesseract --version')
+    try:
+        version = res.stdout_text.split()[1]
+    except IndexError:
+        version = res.stderr_text.split()[1]
+    return int(version.split('.')[0]) == expected_version
+
+    match = re.match(r'tesseract\s(\d)', res)
+    if match is None:
+        return False
+    # now this is guaranteed to be a digit
+    return int(match.groups()[0]) == expected_version