mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
When running algorithm tests, if two parameters share the same
layer source, ensure that the actual parameter values point to the same layer
This commit is contained in:
parent
d9fca48217
commit
05364aa5f0
@ -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 @@ class AlgorithmsTest(object):
|
||||
: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 @@ class AlgorithmsTest(object):
|
||||
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 @@ class TestQgisAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
from processing.core.Processing import Processing
|
||||
Processing.initialize()
|
||||
cls.cleanup_paths = []
|
||||
cls.in_place_layers = {}
|
||||
cls.vector_layer_params = {}
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
|
Loading…
x
Reference in New Issue
Block a user