|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import json
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
@ -40,3 +41,25 @@ def test_cli_json_cer_is_infinity(tmp_path):
|
|
|
|
|
with open("report.json", "r") as jsonf:
|
|
|
|
|
j = json.load(jsonf)
|
|
|
|
|
assert j["cer"] == pytest.approx(float("inf"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.integration
|
|
|
|
|
def test_cli_html(tmp_path):
|
|
|
|
|
"""Test that the cli/process() yields complete HTML report"""
|
|
|
|
|
|
|
|
|
|
with working_directory(tmp_path):
|
|
|
|
|
with open("gt.txt", "w") as gtf:
|
|
|
|
|
gtf.write("AAAAA")
|
|
|
|
|
with open("ocr.txt", "w") as ocrf:
|
|
|
|
|
ocrf.write("AAAAB")
|
|
|
|
|
|
|
|
|
|
process("gt.txt", "ocr.txt", "report")
|
|
|
|
|
|
|
|
|
|
with open("report.html", "r") as htmlf:
|
|
|
|
|
html_report = htmlf.read()
|
|
|
|
|
print(html_report)
|
|
|
|
|
|
|
|
|
|
assert re.search(r"CER: 0\.\d+", html_report)
|
|
|
|
|
assert re.search(r"WER: 1\.0", html_report)
|
|
|
|
|
assert len(re.findall("gt.*cdiff", html_report)) == 1
|
|
|
|
|
assert len(re.findall("gt.*wdiff", html_report)) == 1
|