Skip to content
Permalink
Browse files

improved TestPyQgsAppStartup

allow passing additional arguments after testfile
do not wait the full timeout when the app already exited
  • Loading branch information
SebDieBln committed Nov 22, 2015
1 parent 7840dbe commit 91ad208d92fa14a2afc33a1a5397466efba58d71
Showing with 13 additions and 3 deletions.
  1. +13 −3 tests/src/python/test_qgsappstartup.py
@@ -24,6 +24,7 @@
import shutil
import subprocess
import tempfile
import errno

from utilities import unittest, unitTestDataPath

@@ -47,7 +48,7 @@ def tearDownClass(cls):
# TODO: refactor parameters to **kwargs to handle all startup combinations
def doTestStartup(self, option='', testDir='', testFile='',
loadPlugins=False, customization=False,
timeOut=15, env=None):
timeOut=15, env=None, additionalArguments = []):
"""Run QGIS with the given option. Wait for testFile to be created.
If time runs out, fail.
"""
@@ -75,19 +76,28 @@ def doTestStartup(self, option='', testDir='', testFile='',
myenv.update(env)

p = subprocess.Popen(
[QGIS_BIN, "--nologo", plugins, customize, option, testDir],
[QGIS_BIN, "--nologo", plugins, customize, option, testDir] + additionalArguments,
env=myenv)

s = 0
ok = True
while not os.path.exists(myTestFile):
p.poll()
if p.returncode is not None:
ok = False
break
time.sleep(1)
s += 1
if s > timeOut:
ok = False
break

p.terminate()
try:
p.terminate()
except OSError as e:
if e.errno != errno.ESRCH:
raise

return ok

def testOptionsPath(self):

0 comments on commit 91ad208

Please sign in to comment.
You can’t perform that action at this time.