Skip to content

Commit 05364aa

Browse files
committedJul 6, 2017
When running algorithm tests, if two parameters share the same
layer source, ensure that the actual parameter values point to the same layer
1 parent d9fca48 commit 05364aa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
 

‎python/plugins/processing/tests/AlgorithmsTestBase.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def processingTestDataPath():
7777

7878
class AlgorithmsTest(object):
7979

80-
in_place_layers = {}
81-
8280
def test_algorithms(self):
8381
"""
8482
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):
9694
:param name: The identifier name used in the test output heading
9795
:param defs: A python dict containing a test algorithm definition
9896
"""
97+
self.vector_layer_params = {}
9998
QgsProject.instance().removeAllMapLayers()
10099

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

218217
if param['type'] in ('vector', 'table'):
218+
if filepath in self.vector_layer_params:
219+
return self.vector_layer_params[filepath]
220+
219221
lyr = QgsVectorLayer(filepath, param['name'], 'ogr', False)
222+
self.vector_layer_params[filepath] = lyr
220223
elif param['type'] == 'raster':
221224
lyr = QgsRasterLayer(filepath, param['name'], 'gdal', False)
222225

‎python/plugins/processing/tests/QgisAlgorithmsTest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def setUpClass(cls):
6464
from processing.core.Processing import Processing
6565
Processing.initialize()
6666
cls.cleanup_paths = []
67+
cls.in_place_layers = {}
68+
cls.vector_layer_params = {}
6769

6870
@classmethod
6971
def tearDownClass(cls):

0 commit comments

Comments
 (0)
Please sign in to comment.