Skip to content

Commit

Permalink
When running algorithm tests, if two parameters share the same
Browse files Browse the repository at this point in the history
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 05364aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -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
Expand All @@ -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'])
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions python/plugins/processing/tests/QgisAlgorithmsTest.py
Expand Up @@ -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):
Expand Down

0 comments on commit 05364aa

Please sign in to comment.