From a36b406ea1e47f328373168d2d771842e9750753 Mon Sep 17 00:00:00 2001 From: Bozho Dimitrov <1278836+bozhodimitrov@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:23:47 +0000 Subject: [PATCH] Add test case for language tags pattern GitHub issue: madmaze#552 --- .github/workflows/ci.yaml | 2 +- tests/pytesseract_test.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0f96a56..44cfce4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,4 +45,4 @@ jobs: run: tox -e ${{ matrix.env != env.PYTHON_LATEST_TAG && matrix.env || 'pandas' }} - name: Test pytesseract package installation if: ${{ matrix.env == env.PYTHON_LATEST_TAG }} - run: python -mpip install -U . && python -mpip show pytesseract && python -c 'import pytesseract' \ No newline at end of file + run: python -mpip install -U . && python -mpip show pytesseract && python -c 'import pytesseract' diff --git a/tests/pytesseract_test.py b/tests/pytesseract_test.py index 0afaa6e..3a54c71 100644 --- a/tests/pytesseract_test.py +++ b/tests/pytesseract_test.py @@ -27,6 +27,7 @@ from pytesseract import TesseractNotFoundError from pytesseract import TSVNotSupported from pytesseract.pytesseract import file_to_dict +from pytesseract.pytesseract import LANG_PATTERN from pytesseract.pytesseract import numpy_installed from pytesseract.pytesseract import pandas_installed from pytesseract.pytesseract import prepare @@ -518,3 +519,20 @@ def test_get_tesseract_version_invalid(tesseract_version, expected_msg): (msg,) = e.value.args assert msg == expected_msg + + +@pytest.mark.parametrize( + 'lang', + [ + 'bhu', + 'eng', + 'bhu_eng', + 'eng_bhu', + '7seg', + 'bhu32', + 'bhu32_7seg', + '7seg_eng', + ], +) +def test_allowed_language_formats(lang): + assert LANG_PATTERN.match(lang)