diff --git a/python/testing/__init__.py b/python/testing/__init__.py index b9b42eb07ba..e0942880606 100644 --- a/python/testing/__init__.py +++ b/python/testing/__init__.py @@ -223,7 +223,7 @@ unittest.TestCase = TestCase unittest.expectedFailure = expectedFailure -def start_app(): +def start_app(cleanup=True): """ Will start a QgsApplication and call all initialization code like registering the providers and other infrastructure. It will not load @@ -233,6 +233,11 @@ def start_app(): The initialization will only happen once, so it is safe to call this method repeatedly. + Parameters + ---------- + + cleanup: Do cleanup on exit. Defaults to true. + Returns ------- QgsApplication @@ -258,14 +263,14 @@ def start_app(): QGISAPP = QgsApplication(argvb, myGuiFlag) QGISAPP.initQgis() - s = QGISAPP.showSettings() - print(s) + print(QGISAPP.showSettings()) - import atexit + if cleanup: + import atexit - @atexit.register - def exitQgis(): - QGISAPP.exitQgis() + @atexit.register + def exitQgis(): + QGISAPP.exitQgis() return QGISAPP diff --git a/tests/src/python/test_provider_spatialite.py b/tests/src/python/test_provider_spatialite.py index 6f6e9b2bb92..f046a520f57 100644 --- a/tests/src/python/test_provider_spatialite.py +++ b/tests/src/python/test_provider_spatialite.py @@ -15,6 +15,7 @@ __revision__ = '$Format:%H$' import qgis # NOQA import os +import sys import shutil import tempfile @@ -31,8 +32,8 @@ except ImportError: print("You should install pyspatialite to run the tests") raise ImportError -# Convenience instances in case you may need them -start_app() +# Pass no_exit=True: for some reason this crashes on exit on Travis MacOSX +start_app(sys.platform != 'darwin') TEST_DATA_DIR = unitTestDataPath() diff --git a/tests/src/python/test_qgspallabeling_base.py b/tests/src/python/test_qgspallabeling_base.py index 29ff8af7d1a..7ec7e05ad37 100644 --- a/tests/src/python/test_qgspallabeling_base.py +++ b/tests/src/python/test_qgspallabeling_base.py @@ -55,7 +55,7 @@ from utilities import ( ) -start_app() +start_app(sys.platform != 'darwin') # No cleanup on mac os x, it crashes the pallabellingcanvas test on exit FONTSLOADED = loadTestFonts() PALREPORT = 'PAL_REPORT' in os.environ