Skip to content

Commit

Permalink
✅ Add test to check if we warn when processing a "raw"/RGB image with…
Browse files Browse the repository at this point in the history
… a single-channel model
  • Loading branch information
mikegerber committed Dec 5, 2019
1 parent f20eb3b commit 377466a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/test_recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import urllib.request

import pytest
import logging
from ocrd.resolver import Resolver

from ocrd_calamari import CalamariRecognize
Expand Down Expand Up @@ -61,3 +62,16 @@ def test_recognize(workspace):
assert os.path.exists(page1)
with open(page1, 'r', encoding='utf-8') as f:
assert 'verſchuldeten' in f.read()


def test_recognize_should_warn_if_given_rgb_image_and_single_channel_model(workspace, caplog):
caplog.set_level(logging.WARNING)
CalamariRecognize(
workspace,
input_file_grp="OCR-D-GT-SEG-LINE",
output_file_grp="OCR-D-OCR-CALAMARI-BROKEN",
parameter={'checkpoint': CHECKPOINT}
).process()

interesting_log_messages = [t[2] for t in caplog.record_tuples if "Using raw image" in t[2]]
assert len(interesting_log_messages) > 10 # For every line!

0 comments on commit 377466a

Please sign in to comment.