mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-11-10 06:34:11 +01:00
refactor cli tests
This commit is contained in:
parent
ef999c8f0a
commit
b6f82c72b9
15 changed files with 453 additions and 592 deletions
58
tests/cli_tests/test_binarization.py
Normal file
58
tests/cli_tests/test_binarization.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import pytest
|
||||
from PIL import Image
|
||||
from eynollah.cli import (
|
||||
binarization as binarization_cli,
|
||||
)
|
||||
from ocrd_modelfactory import page_from_file
|
||||
from ocrd_models.constants import NAMESPACES as NS
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"options",
|
||||
[
|
||||
[], # defaults
|
||||
["--no-patches"],
|
||||
], ids=str)
|
||||
def test_run_eynollah_binarization_filename(
|
||||
tmp_path,
|
||||
run_eynollah_ok_and_check_logs,
|
||||
tests_dir,
|
||||
options,
|
||||
):
|
||||
infile = tests_dir.joinpath('resources/kant_aufklaerung_1784_0020.tif')
|
||||
outfile = tmp_path.joinpath('kant_aufklaerung_1784_0020.png')
|
||||
run_eynollah_ok_and_check_logs(
|
||||
binarization_cli,
|
||||
[
|
||||
'-i', str(infile),
|
||||
'-o', str(outfile),
|
||||
] + options,
|
||||
[
|
||||
'Predicting'
|
||||
]
|
||||
)
|
||||
assert outfile.exists()
|
||||
with Image.open(infile) as original_img:
|
||||
original_size = original_img.size
|
||||
with Image.open(outfile) as binarized_img:
|
||||
binarized_size = binarized_img.size
|
||||
assert original_size == binarized_size
|
||||
|
||||
def test_run_eynollah_binarization_directory(
|
||||
tmp_path,
|
||||
run_eynollah_ok_and_check_logs,
|
||||
resources_dir,
|
||||
image_resources,
|
||||
):
|
||||
outdir = tmp_path
|
||||
run_eynollah_ok_and_check_logs(
|
||||
binarization_cli,
|
||||
[
|
||||
'-di', str(resources_dir),
|
||||
'-o', str(outdir),
|
||||
],
|
||||
[
|
||||
f'Predicting {image_resources[0].name}',
|
||||
f'Predicting {image_resources[1].name}',
|
||||
]
|
||||
)
|
||||
assert len(list(outdir.iterdir())) == 2
|
||||
Loading…
Add table
Add a link
Reference in a new issue