Skip to content

Commit

Permalink
Cleanup temporary python test config path when requested
Browse files Browse the repository at this point in the history
References #48884
  • Loading branch information
strk committed Oct 20, 2022
1 parent dbfa13b commit fdbe82a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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

Expand Down

0 comments on commit fdbe82a

Please sign in to comment.