Workaround for buggy mac osx cleanup

This commit is contained in:
Matthias Kuhn 2016-04-14 19:33:29 +02:00
parent aa0b9fa895
commit 816c322df5
3 changed files with 16 additions and 10 deletions

View File

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

View File

@ -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()

View File

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