@@ -76,50 +76,43 @@ def doTestStartup(self, option='', testDir='', testFile='',
76
76
if env is not None :
77
77
myenv .update (env )
78
78
79
- p = subprocess .Popen (
80
- [QGIS_BIN , "--nologo" , plugins , customize , option , testDir ] + additionalArguments ,
81
- env = myenv )
79
+ call = [QGIS_BIN , "--nologo" , plugins , customize , option , testDir ] + additionalArguments
80
+ p = subprocess .Popen (call , env = myenv )
82
81
83
82
s = 0
84
83
ok = True
85
84
while not os .path .exists (myTestFile ):
86
85
p .poll ()
87
86
if p .returncode is not None :
88
- print ('Application has returned: {}' .format (p .returncode ))
89
- ok = False
90
- break
87
+ raise Exception ('Return code: {}, Call: "{}", Env: {}' .format (p .returncode , ' ' .join (call ), env ))
91
88
time .sleep (1 )
92
89
s += 1
93
90
if s > timeOut :
94
- print ('Timed out waiting for application start' )
95
- ok = False
96
- break
91
+ raise Exception ('Timed out waiting for application start, Call: "{}", Env: {}' .format (' ' .join (call ), env ))
97
92
98
93
try :
99
94
p .terminate ()
100
95
except OSError as e :
101
96
if e .errno != errno .ESRCH :
102
- raise
103
-
104
- return ok
97
+ raise e
105
98
106
99
def testOptionsPath (self ):
107
100
subdir = 'QGIS' # Linux
108
101
if sys .platform [:3 ] == 'dar' : # Mac
109
102
subdir = 'qgis.org'
110
103
ini = os .path .join (subdir , 'QGIS2.ini' )
111
104
for p in ['test_opts' , 'test opts' , u'test_optsé€' ]:
112
- assert self .doTestStartup (option = "--optionspath" ,
113
- testDir = os .path .join (self .TMP_DIR , p ),
114
- testFile = ini ,
115
- timeOut = 270 ), "options path %s" % p
105
+ self .doTestStartup (option = "--optionspath" ,
106
+ testDir = os .path .join (self .TMP_DIR , p ),
107
+ testFile = ini ,
108
+ timeOut = 270 )
116
109
117
110
def testConfigPath (self ):
118
111
for p in ['test_config' , 'test config' , u'test_configé€' ]:
119
- assert self .doTestStartup (option = "--configpath" ,
120
- testDir = os .path .join (self .TMP_DIR , p ),
121
- testFile = "qgis.db" ,
122
- timeOut = 270 ), "config path %s" % p
112
+ self .doTestStartup (option = "--configpath" ,
113
+ testDir = os .path .join (self .TMP_DIR , p ),
114
+ testFile = "qgis.db" ,
115
+ timeOut = 270 )
123
116
124
117
def testPluginPath (self ):
125
118
for t in ['test_plugins' , 'test plugins' , u'test_pluginsé€' ]:
@@ -138,7 +131,7 @@ def testPluginPath(self):
138
131
# we use here a minimal plugin that writes to 'plugin_started.txt'
139
132
# when it is started. if QGIS_PLUGINPATH is correctly parsed, this
140
133
# plugin is executed and the file is created
141
- assert self .doTestStartup (
134
+ self .doTestStartup (
142
135
option = "--optionspath" ,
143
136
testDir = testDir ,
144
137
testFile = "plugin_started.txt" ,
@@ -160,22 +153,26 @@ def testPyQgisStartupEnvVar(self):
160
153
f = open (testmod , 'w' )
161
154
f .writelines (testcode )
162
155
f .close ()
163
- msg = 'Creation of test file by executing PYQGIS_STARTUP file failed'
164
- assert self .doTestStartup (
156
+ self .doTestStartup (
165
157
testFile = testfilepath ,
166
158
timeOut = 270 ,
167
- env = {'PYQGIS_STARTUP' : testmod }), msg
159
+ env = {'PYQGIS_STARTUP' : testmod })
168
160
169
161
def testOptionsAsFiles (self ):
170
162
# verify QGIS accepts filenames that match options after the special option '--'
171
163
# '--help' should return immediatly (after displaying the usage hints)
172
164
# '-- --help' should not exit but try (and probably fail) to load a layer called '--help'
173
- for t in [(False , ['--help' ]), (True , ['--' , '--help' ])]:
174
- assert t [0 ] == self .doTestStartup (option = "--configpath" ,
175
- testDir = os .path .join (self .TMP_DIR , 'test_optionsAsFiles' ),
176
- testFile = "qgis.db" ,
177
- timeOut = 270 ,
178
- additionalArguments = t [1 ]), "additional arguments: %s" % ' ' .join (t [1 ])
165
+ with self .assertRaises (Exception ):
166
+ self .doTestStartup (option = "--configpath" ,
167
+ testDir = os .path .join (self .TMP_DIR , 'test_optionsAsFiles' ),
168
+ testFile = "qgis.db" ,
169
+ timeOut = 270 ,
170
+ additionalArguments = ['--help' ]), "additional arguments: %s" % ' ' .join (t [1 ])
171
+ self .doTestStartup (option = "--configpath" ,
172
+ testDir = os .path .join (self .TMP_DIR , 'test_optionsAsFiles' ),
173
+ testFile = "qgis.db" ,
174
+ timeOut = 270 ,
175
+ additionalArguments = ['--' ], ['--help' ]), "additional arguments: %s" % ' ' .join (t [1 ])
179
176
180
177
181
178
if __name__ == '__main__' :
0 commit comments