@@ -114,7 +114,8 @@ def check_algorithm(self, name, defs):
114
114
parameters [k ] = p
115
115
116
116
for r , p in list (defs ['results' ].items ()):
117
- parameters [r ] = self .load_result_param (p )
117
+ if not 'in_place_result' in p or not p ['in_place_result' ]:
118
+ parameters [r ] = self .load_result_param (p )
118
119
119
120
expectFailure = False
120
121
if 'expectedFailure' in defs :
@@ -136,7 +137,7 @@ def check_algorithm(self, name, defs):
136
137
pass
137
138
else :
138
139
results , ok = alg .run (parameters , context , feedback )
139
- self .assertTrue (ok )
140
+ self .assertTrue (ok , parameters )
140
141
self .check_results (results , context , defs ['params' ], defs ['results' ])
141
142
142
143
def load_params (self , params ):
@@ -202,26 +203,23 @@ def load_layer(self, id, param):
202
203
"""
203
204
filepath = self .filepath_from_param (param )
204
205
205
- try :
206
+ if 'in_place' in param and param [ 'in_place' ] :
206
207
# check if alg modifies layer in place
207
- if param ['in_place' ]:
208
- tmpdir = tempfile .mkdtemp ()
209
- self .cleanup_paths .append (tmpdir )
210
- path , file_name = os .path .split (filepath )
211
- base , ext = os .path .splitext (file_name )
212
- for file in glob .glob (os .path .join (path , '{}.*' .format (base ))):
213
- shutil .copy (os .path .join (path , file ), tmpdir )
214
- filepath = os .path .join (tmpdir , file_name )
215
- self .in_place_layers [id ] = filepath
216
- except :
217
- pass
208
+ tmpdir = tempfile .mkdtemp ()
209
+ self .cleanup_paths .append (tmpdir )
210
+ path , file_name = os .path .split (filepath )
211
+ base , ext = os .path .splitext (file_name )
212
+ for file in glob .glob (os .path .join (path , '{}.*' .format (base ))):
213
+ shutil .copy (os .path .join (path , file ), tmpdir )
214
+ filepath = os .path .join (tmpdir , file_name )
215
+ self .in_place_layers [id ] = filepath
218
216
219
217
if param ['type' ] in ('vector' , 'table' ):
220
218
lyr = QgsVectorLayer (filepath , param ['name' ], 'ogr' )
221
219
elif param ['type' ] == 'raster' :
222
220
lyr = QgsRasterLayer (filepath , param ['name' ], 'gdal' )
223
221
224
- self .assertTrue (lyr .isValid (), 'Could not load layer "{}"' .format (filepath ))
222
+ self .assertTrue (lyr .isValid (), 'Could not load layer "{}" from param {} ' .format (filepath , param ))
225
223
QgsProject .instance ().addMapLayer (lyr )
226
224
return lyr
227
225
@@ -241,6 +239,12 @@ def check_results(self, results, context, params, expected):
241
239
"""
242
240
for id , expected_result in list (expected .items ()):
243
241
if expected_result ['type' ] in ('vector' , 'table' ):
242
+ if 'compare' in expected_result and not expected_result ['compare' ]:
243
+ # skipping the comparison, so just make sure output is valid
244
+ result_lyr = QgsProcessingUtils .mapLayerFromString (results [id ], context )
245
+ self .assertTrue (result_lyr .isValid ())
246
+ continue
247
+
244
248
expected_lyr = self .load_layer (id , expected_result )
245
249
if 'in_place_result' in expected_result :
246
250
result_lyr = QgsProcessingUtils .mapLayerFromString (self .in_place_layers [id ], context )
0 commit comments