From 377466a71ad76a73f8f1cd246a3484a478fc2296 Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Thu, 5 Dec 2019 14:59:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20test=20to=20check=20if=20we?= =?UTF-8?q?=20warn=20when=20processing=20a=20"raw"/RGB=20image=20with=20a?= =?UTF-8?q?=20single-channel=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_recognize.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_recognize.py b/test/test_recognize.py index 19932f4..f97ef91 100644 --- a/test/test_recognize.py +++ b/test/test_recognize.py @@ -4,6 +4,7 @@ import subprocess import urllib.request import pytest +import logging from ocrd.resolver import Resolver from ocrd_calamari import CalamariRecognize @@ -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!