1
0
Fork 0
mirror of https://github.com/mikegerber/ocrd_calamari.git synced 2025-06-26 03:59:53 +02:00

🔐 Use a safe temporary directory for the test workspace

This commit is contained in:
Gerber, Mike 2022-09-15 17:00:22 +02:00
parent 395e43c074
commit 9866b06e87

View file

@ -1,6 +1,7 @@
import os import os
import shutil import shutil
import subprocess import subprocess
import tempfile
import urllib.request import urllib.request
from lxml import etree from lxml import etree
from glob import glob from glob import glob
@ -13,7 +14,7 @@ from ocrd_calamari import CalamariRecognize
from .base import assets from .base import assets
METS_KANT = assets.url_of('kant_aufklaerung_1784-page-region-line-word_glyph/data/mets.xml') METS_KANT = assets.url_of('kant_aufklaerung_1784-page-region-line-word_glyph/data/mets.xml')
WORKSPACE_DIR = '/tmp/test-ocrd-calamari' WORKSPACE_DIR = tempfile.mkdtemp(prefix='test-ocrd-calamari-')
CHECKPOINT_DIR = os.getenv('MODEL') CHECKPOINT_DIR = os.getenv('MODEL')
@ -80,7 +81,9 @@ def workspace():
tree.write(path, xml_declaration=True, encoding="utf-8") tree.write(path, xml_declaration=True, encoding="utf-8")
assertFileDoesNotContain(path, "TextEquiv") assertFileDoesNotContain(path, "TextEquiv")
return workspace yield workspace
shutil.rmtree(WORKSPACE_DIR)
def test_recognize(workspace): def test_recognize(workspace):