Skip to content

Commit

Permalink
Skip Tesseract installation test if installed locally
Browse files Browse the repository at this point in the history
  • Loading branch information
xavctn committed Feb 25, 2023
1 parent 277f8ae commit 5c8eaed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion tests/ocr/tesseract/test_tesseract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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()

Expand Down

0 comments on commit 5c8eaed

Please sign in to comment.