From 5c8eaed6be34669c074f544f0ee57683351ae608 Mon Sep 17 00:00:00 2001 From: Xavier C Date: Sun, 26 Feb 2023 00:49:34 +0100 Subject: [PATCH] Skip Tesseract installation test if installed locally --- tests/__init__.py | 3 +++ tests/ocr/tesseract/test_tesseract.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/__init__.py b/tests/__init__.py index 7770cbd..f8ed2df 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +1,9 @@ # coding: utf-8 import os +import subprocess CWD = os.path.dirname(__file__) MOCK_DIR = os.path.join(CWD, "_mock_data") + +TESSERACT_INSTALL = subprocess.run("tesseract --version", shell=True).returncode == 0 diff --git a/tests/ocr/tesseract/test_tesseract.py b/tests/ocr/tesseract/test_tesseract.py index c91ec87..124e75b 100644 --- a/tests/ocr/tesseract/test_tesseract.py +++ b/tests/ocr/tesseract/test_tesseract.py @@ -8,7 +8,7 @@ from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.ocr.data import OCRDataframe -from tests import MOCK_DIR +from tests import MOCK_DIR, TESSERACT_INSTALL def test_validators(): @@ -18,6 +18,9 @@ def test_validators(): with pytest.raises(TypeError) as e_info: ocr = TesseractOCR(lang=12) + +@pytest.mark.skipif(TESSERACT_INSTALL, reason="Tesseract installed locally") +def test_installed(): with pytest.raises(EnvironmentError) as e_info: ocr = TesseractOCR()