Skip to content

Commit

Permalink
improved TestPyQgsAppStartup
Browse files Browse the repository at this point in the history
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 91ad208
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/src/python/test_qgsappstartup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import shutil
import subprocess
import tempfile
import errno

from utilities import unittest, unitTestDataPath

Expand All @@ -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.
"""
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 91ad208

Please sign in to comment.