@@ -137,10 +137,10 @@ def load_param(self, param):
137
137
138
138
def load_result_param (self , param ):
139
139
"""
140
- Lodas a result parameter. Creates a temporary destination where the result should go to and returns this location
140
+ Loads a result parameter. Creates a temporary destination where the result should go to and returns this location
141
141
so it can be sent to the algorithm as parameter.
142
142
"""
143
- if param ['type' ] == 'vector' :
143
+ if param ['type' ] in [ 'vector' , 'file' ] :
144
144
outdir = tempfile .mkdtemp ()
145
145
self .cleanup_paths .append (outdir )
146
146
basename = os .path .basename (param ['name' ])
@@ -153,14 +153,7 @@ def load_layer(self, param):
153
153
"""
154
154
Loads a layer which was specified as parameter.
155
155
"""
156
- prefix = processingTestDataPath ()
157
- try :
158
- if param ['location' ] == 'qgs' :
159
- prefix = unitTestDataPath ()
160
- except KeyError :
161
- pass
162
-
163
- filepath = os .path .join (prefix , param ['name' ])
156
+ filepath = self .filepath_from_param (param )
164
157
165
158
if param ['type' ] == 'vector' :
166
159
lyr = QgsVectorLayer (filepath , param ['name' ], 'ogr' )
@@ -171,6 +164,16 @@ def load_layer(self, param):
171
164
QgsMapLayerRegistry .instance ().addMapLayer (lyr )
172
165
return lyr
173
166
167
+ def filepath_from_param (self , param ):
168
+ """
169
+ Creates a filepath from a param
170
+ """
171
+ prefix = processingTestDataPath ()
172
+ if 'location' in param and param ['location' ] == 'qgs' :
173
+ prefix = unitTestDataPath ()
174
+
175
+ return os .path .join (prefix , param ['name' ])
176
+
174
177
def check_results (self , results , expected ):
175
178
"""
176
179
Checks if result produced by an algorithm matches with the expected specification.
@@ -197,6 +200,11 @@ def check_results(self, results, expected):
197
200
strhash = hashlib .sha224 (dataset .ReadAsArray (0 ).data ).hexdigest ()
198
201
199
202
self .assertEqual (strhash , expected_result ['hash' ])
203
+ elif 'file' == expected_result ['type' ]:
204
+ expected_filepath = self .filepath_from_param (expected_result )
205
+ result_filepath = results [id ]
206
+
207
+ self .assertFilesEqual (expected_filepath , result_filepath )
200
208
201
209
202
210
if __name__ == '__main__' :
0 commit comments