-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Test EasyOCR | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- ci | ||
- release/* | ||
- feature/* | ||
tags: | ||
- v* | ||
paths-ignore: | ||
- README* | ||
pull_request: | ||
|
||
jobs: | ||
test_linux: | ||
name: Test ${{ matrix.os }} with Python ${{ matrix.python }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
python: "3.11" | ||
tesseract5: true | ||
- os: ubuntu-latest | ||
python: "3.12" | ||
tesseract5: true | ||
env: | ||
OS: ${{ matrix.os }} | ||
PYTHON: ${{ matrix.python }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags | ||
|
||
- uses: actions/setup-python@v4 | ||
name: Setup Python | ||
with: | ||
python-version: ${{ matrix.python }} | ||
cache: "pip" | ||
|
||
- name: Install Tesseract 5 | ||
if: matrix.tesseract5 | ||
run: | | ||
sudo add-apt-repository -y ppa:alex-p/tesseract-ocr-devel | ||
- name: Install common packages | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y --no-install-recommends \ | ||
curl \ | ||
ghostscript \ | ||
img2pdf \ | ||
libexempi8 \ | ||
libffi-dev \ | ||
libsm6 libxext6 libxrender-dev \ | ||
pngquant \ | ||
poppler-utils \ | ||
tesseract-ocr \ | ||
tesseract-ocr-deu \ | ||
tesseract-ocr-eng \ | ||
tesseract-ocr-osd \ | ||
unpaper \ | ||
zlib1g | ||
- name: Install Python packages | ||
run: | | ||
python -m pip install --upgrade pip wheel | ||
python -m pip install --prefer-binary .[test] | ||
- name: Report versions | ||
run: | | ||
tesseract --version | ||
gs --version | ||
pngquant --version | ||
unpaper --version | ||
img2pdf --version | ||
- name: Test | ||
run: | | ||
python -m pytest tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SPDX-FileCopyrightText: 2023 James R. Barlow | ||
# SPDX-License-Identifier: MIT | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
TESTS_ROOT = Path(__file__).parent.resolve() | ||
PROJECT_ROOT = TESTS_ROOT | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def resources() -> Path: | ||
return Path(TESTS_ROOT) / "resources" | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def outdir(tmp_path) -> Path: | ||
return tmp_path | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def outpdf(tmp_path) -> Path: | ||
return tmp_path / "out.pdf" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-FileCopyrightText: 2023 James R. Barlow | ||
# SPDX-License-Identifier: MIT | ||
|
||
import ocrmypdf | ||
import pikepdf | ||
import pytest | ||
|
||
import ocrmypdf_easyocr | ||
|
||
|
||
def test_easyocr(resources, outpdf): | ||
ocrmypdf.ocr(resources / "jbig2.pdf", outpdf) | ||
assert outpdf.exists() | ||
|
||
with pikepdf.open(outpdf) as pdf: | ||
assert "EasyOCR" in str(pdf.docinfo["/Creator"]) |