From 5a2af52d55337446cce94f7e335f9bdcd96c159d Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Sun, 20 Oct 2024 16:27:30 +0200 Subject: [PATCH] fix transcription interface tests --- tests/test_transcribe.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/test_transcribe.py b/tests/test_transcribe.py index 044779813..11d02ceab 100644 --- a/tests/test_transcribe.py +++ b/tests/test_transcribe.py @@ -8,6 +8,7 @@ from lxml import etree from PIL import Image +from kraken import containers from kraken.transcribe import TranscriptionInterface thisfile = Path(__file__).resolve().parent @@ -18,16 +19,25 @@ class TestTranscriptionInterface(unittest.TestCase): """ Test of the transcription interface generation """ + def setUp(self): + with open(resources /'records.json', 'r') as fp: + self.box_records = [containers.BBoxOCRRecord(**x) for x in json.load(fp)] + + self.box_segmentation = containers.Segmentation(type='bbox', + imagename='foo.png', + text_direction='horizontal-lr', + lines=self.box_records, + script_detection=True, + regions={}) + + self.im = Image.open(resources / 'input.jpg') def test_transcription_generation(self): """ Tests creation of transcription interfaces with segmentation. """ tr = TranscriptionInterface() - with open(resources / 'segmentation.json') as fp: - seg = json.load(fp) - with Image.open(resources / 'input.jpg') as im: - tr.add_page(im, seg) + tr.add_page(im = self.im, segmentation=self.box_segmentation) fp = BytesIO() tr.write(fp) # this will not throw an exception ever so we need a better validator