Skip to content

Commit

Permalink
Workaround for buggy mac osx cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 15, 2016
1 parent aa0b9fa commit 816c322
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
19 changes: 12 additions & 7 deletions python/testing/__init__.py
Expand Up @@ -223,7 +223,7 @@ def wrapper(*args, **kwargs):
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
Expand All @@ -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
Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions tests/src/python/test_provider_spatialite.py
Expand Up @@ -15,6 +15,7 @@
import qgis # NOQA

import os
import sys
import shutil
import tempfile

Expand All @@ -31,8 +32,8 @@
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()


Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgspallabeling_base.py
Expand Up @@ -55,7 +55,7 @@
)


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
Expand Down

0 comments on commit 816c322

Please sign in to comment.