From 9866b06e879ce0617043d021cfc95a27a21f238c Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Thu, 15 Sep 2022 17:00:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=90=20Use=20a=20safe=20temporary=20dir?= =?UTF-8?q?ectory=20for=20the=20test=20workspace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_recognize.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_recognize.py b/test/test_recognize.py index f02d738..dbb0d1f 100644 --- a/test/test_recognize.py +++ b/test/test_recognize.py @@ -1,6 +1,7 @@ import os import shutil import subprocess +import tempfile import urllib.request from lxml import etree from glob import glob @@ -13,7 +14,7 @@ from ocrd_calamari import CalamariRecognize from .base import assets 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') @@ -80,7 +81,9 @@ def workspace(): tree.write(path, xml_declaration=True, encoding="utf-8") assertFileDoesNotContain(path, "TextEquiv") - return workspace + yield workspace + + shutil.rmtree(WORKSPACE_DIR) def test_recognize(workspace):