From b43f2b04224fcab06af8f1a79d4c36abb3a1992f Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 19 Oct 2022 17:45:58 +0200 Subject: [PATCH] Cleanup temporary python test config path when requested References #48884 --- python/testing/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/testing/__init__.py b/python/testing/__init__.py index 05b769c4962c..cf4f34c38e48 100644 --- a/python/testing/__init__.py +++ b/python/testing/__init__.py @@ -552,7 +552,9 @@ def start_app(cleanup=True): # no need to mess with it here. QGISAPP = QgsApplication(argvb, myGuiFlag) - os.environ['QGIS_CUSTOM_CONFIG_PATH'] = tempfile.mkdtemp('', 'QGIS-PythonTestConfigPath') + tmpdir = tempfile.mkdtemp('', 'QGIS-PythonTestConfigPath-') + os.environ['QGIS_CUSTOM_CONFIG_PATH'] = tmpdir + QGISAPP.initQgis() print(QGISAPP.showSettings()) @@ -563,10 +565,12 @@ def debug_log_message(message, tag, level): if cleanup: import atexit + import shutil @atexit.register def exitQgis(): QGISAPP.exitQgis() + shutil.rmtree(tmpdir) return QGISAPP