@@ -137,10 +137,10 @@ def load_param(self, param):
137137
138138 def load_result_param (self , param ):
139139 """
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
141141 so it can be sent to the algorithm as parameter.
142142 """
143- if param ['type' ] == 'vector' :
143+ if param ['type' ] in [ 'vector' , 'file' ] :
144144 outdir = tempfile .mkdtemp ()
145145 self .cleanup_paths .append (outdir )
146146 basename = os .path .basename (param ['name' ])
@@ -153,14 +153,7 @@ def load_layer(self, param):
153153 """
154154 Loads a layer which was specified as parameter.
155155 """
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 )
164157
165158 if param ['type' ] == 'vector' :
166159 lyr = QgsVectorLayer (filepath , param ['name' ], 'ogr' )
@@ -171,6 +164,16 @@ def load_layer(self, param):
171164 QgsMapLayerRegistry .instance ().addMapLayer (lyr )
172165 return lyr
173166
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+
174177 def check_results (self , results , expected ):
175178 """
176179 Checks if result produced by an algorithm matches with the expected specification.
@@ -197,6 +200,11 @@ def check_results(self, results, expected):
197200 strhash = hashlib .sha224 (dataset .ReadAsArray (0 ).data ).hexdigest ()
198201
199202 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 )
200208
201209
202210if __name__ == '__main__' :
0 commit comments