eynollah/tests/cli_tests/test_binarization.py
Robert Sachunsky 4406a0299e update CLI test for binarization…
- update expected log messages
2026-05-09 04:12:19 +02:00

53 lines
1.3 KiB
Python

import pytest
from PIL import Image
@pytest.mark.parametrize(
"options",
[
[], # defaults
["--no-patches"],
], ids=str)
def test_run_eynollah_binarization_filename(
tmp_path,
run_eynollah_ok_and_check_logs,
resources_dir,
options,
):
infile = resources_dir / '2files/kant_aufklaerung_1784_0020.tif'
outfile = tmp_path / 'kant_aufklaerung_1784_0020.png'
run_eynollah_ok_and_check_logs(
'binarization',
[
'-i', str(infile),
'-o', str(outfile),
] + options,
[
f"output filename: '{str(outfile)}'"
]
)
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',
[
'-di', str(resources_dir / '2files'),
'-o', str(outdir),
],
[
str(image_resources[0]),
str(image_resources[1]),
]
)
assert len(list(outdir.iterdir())) == 2