Skip to content
Permalink
Browse files

When running algorithm tests, if two parameters share the same

layer source, ensure that the actual parameter values point
to the same layer
  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent d9fca48 commit 05364aa5f0038a79631e80aff26dbbc5dc136f5d
@@ -77,8 +77,6 @@ def processingTestDataPath():

class AlgorithmsTest(object):

in_place_layers = {}

def test_algorithms(self):
"""
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
@@ -96,6 +94,7 @@ def check_algorithm(self, name, defs):
:param name: The identifier name used in the test output heading
:param defs: A python dict containing a test algorithm definition
"""
self.vector_layer_params = {}
QgsProject.instance().removeAllMapLayers()

params = self.load_params(defs['params'])
@@ -216,7 +215,11 @@ def load_layer(self, id, param):
self.in_place_layers[id] = filepath

if param['type'] in ('vector', 'table'):
if filepath in self.vector_layer_params:
return self.vector_layer_params[filepath]

lyr = QgsVectorLayer(filepath, param['name'], 'ogr', False)
self.vector_layer_params[filepath] = lyr
elif param['type'] == 'raster':
lyr = QgsRasterLayer(filepath, param['name'], 'gdal', False)

@@ -64,6 +64,8 @@ def setUpClass(cls):
from processing.core.Processing import Processing
Processing.initialize()
cls.cleanup_paths = []
cls.in_place_layers = {}
cls.vector_layer_params = {}

@classmethod
def tearDownClass(cls):

0 comments on commit 05364aa

Please sign in to comment.
You can’t perform that action at this time.