From b03116f4a6d61d5755ac13d43742ac30941aa7d8 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Fri, 4 Apr 2025 22:22:50 +0200 Subject: [PATCH] pytest: use subtests for various layout options, add coverage --- Makefile | 11 +++++++-- pyproject.toml | 6 +++++ requirements-test.txt | 2 ++ tests/base.py | 54 ------------------------------------------- tests/test_counter.py | 3 --- tests/test_dpi.py | 3 --- tests/test_run.py | 47 ++++++++++++++++++++++++------------- tests/test_xml.py | 4 ---- 8 files changed, 48 insertions(+), 82 deletions(-) delete mode 100644 tests/base.py diff --git a/Makefile b/Makefile index 27eb872..516dd1a 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ SEG_MODEL := https://qurator-data.de/eynollah/2022-04-05/models_eynollah.tar.gz BIN_MODEL := https://github.com/qurator-spk/sbb_binarization/releases/download/v0.0.11/saved_model_2021_03_09.zip -PYTEST_ARGS ?= +PYTEST_ARGS ?= -vv # BEGIN-EVAL makefile-parser --make-help Makefile @@ -90,6 +90,7 @@ smoke-test: tests/resources/kant_aufklaerung_1784_0020.tif @set -x; test "$$(identify -format '%w %h' $<)" = "$$(identify -format '%w %h' $(TMPDIR)/$( 0: + args.extend(['-l', 'DEBUG']) + runner = CliRunner() + for options in [ + [], # defaults + ["--allow_scaling", "--curved-line"], + ["--allow_scaling", "--curved-line", "--full-layout"], + ["--allow_scaling", "--curved-line", "--full-layout", "--reading_order_machine_based"], + ["--allow_scaling", "--curved-line", "--full-layout", "--reading_order_machine_based", + "--textline_light", "--light_version"], + # -ep ... + # -eoi ... + # --do_ocr + # --skip_layout_and_reading_order + ]: + with subtests.test(#msg="test CLI", + options=options): + result = runner.invoke(eynollah_cli, args + options) + print(result) + print(result.output) + assert result.exit_code == 0 + assert 'kant_aufklaerung_1784_0020.tif' in result.output diff --git a/tests/test_xml.py b/tests/test_xml.py index 09a6ddf..5dffc94 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -1,4 +1,3 @@ -from pytest import main from eynollah.utils.xml import create_page_xml from ocrd_models.ocrd_page import to_xml @@ -9,6 +8,3 @@ def test_create_xml(): xmlstr = to_xml(pcgts) assert 'xmlns:pc="%s"' % PAGE_2019 in xmlstr assert 'Metadata' in xmlstr - -if __name__ == '__main__': - main([__file__])