Skip to content

Commit 8ce3e8b

Browse files
committedNov 23, 2018
Fix unit test
(cherry picked from commit c31a690)
1 parent 5e4ee5c commit 8ce3e8b

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed
 

‎python/plugins/processing/gui/AlgorithmDialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def getParametersPanel(self, alg, parent):
9797

9898
def runAsBatch(self):
9999
self.close()
100-
dlg = BatchAlgorithmDialog(self.algorithm())
100+
dlg = BatchAlgorithmDialog(self.algorithm(), parent=iface.mainWindow())
101101
dlg.show()
102102
dlg.exec_()
103103

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
class AlgorithmDialogTest(unittest.TestCase):
5656

5757
def testCreation(self):
58-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
58+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
5959
a = AlgorithmDialog(alg)
6060
self.assertEqual(a.mainWidget().alg, alg)
6161

@@ -67,7 +67,7 @@ def setUpClass(cls):
6767
ProcessingConfig.initialize()
6868

6969
def checkConstructWrapper(self, param, expected_wrapper_class):
70-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
70+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
7171

7272
# algorithm dialog
7373
dlg = AlgorithmDialog(alg)
@@ -77,6 +77,7 @@ def checkConstructWrapper(self, param, expected_wrapper_class):
7777
self.assertEqual(wrapper.dialog, dlg)
7878
self.assertIsNotNone(wrapper.widget)
7979

80+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
8081
# batch dialog
8182
dlg = BatchAlgorithmDialog(alg)
8283
wrapper = WidgetWrapperFactory.create_wrapper_from_class(param, dlg)
@@ -85,6 +86,8 @@ def checkConstructWrapper(self, param, expected_wrapper_class):
8586
self.assertEqual(wrapper.dialog, dlg)
8687
self.assertIsNotNone(wrapper.widget)
8788

89+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
90+
8891
# modeler dialog
8992
model = QgsProcessingModelAlgorithm()
9093
dlg = ModelerParametersDialog(alg, model)
@@ -138,7 +141,7 @@ def testSource(self):
138141
self.assertTrue(layer.isValid())
139142
QgsProject.instance().addMapLayer(layer)
140143

141-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
144+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
142145
dlg = AlgorithmDialog(alg)
143146
param = QgsProcessingParameterFeatureSource('test')
144147
wrapper = FeatureSourceWidgetWrapper(param, dlg)
@@ -175,7 +178,7 @@ def testRange(self):
175178
# minimal test to check if wrapper generate GUI for each processign context
176179
self.checkConstructWrapper(QgsProcessingParameterRange('test'), RangeWidgetWrapper)
177180

178-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
181+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
179182
dlg = AlgorithmDialog(alg)
180183
param = QgsProcessingParameterRange(
181184
name='test',
@@ -237,7 +240,7 @@ def testMapLayer(self):
237240
def testDistance(self):
238241
self.checkConstructWrapper(QgsProcessingParameterDistance('test'), DistanceWidgetWrapper)
239242

240-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
243+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
241244
dlg = AlgorithmDialog(alg)
242245
param = QgsProcessingParameterDistance('test')
243246
wrapper = DistanceWidgetWrapper(param, dlg)
@@ -322,7 +325,7 @@ def testDistance(self):
322325
def testMatrix(self):
323326
self.checkConstructWrapper(QgsProcessingParameterMatrix('test'), FixedTableWidgetWrapper)
324327

325-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
328+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
326329
dlg = AlgorithmDialog(alg)
327330
param = QgsProcessingParameterMatrix('test', 'test', 2, True, ['x', 'y'], [['a', 'b'], ['c', 'd']])
328331
wrapper = FixedTableWidgetWrapper(param, dlg)
@@ -346,7 +349,7 @@ def testBand(self):
346349

347350
def testFeatureSink(self):
348351
param = QgsProcessingParameterFeatureSink('test')
349-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
352+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
350353
panel = DestinationSelectionPanel(param, alg)
351354

352355
panel.setValue('memory:')
@@ -382,7 +385,7 @@ def testFeatureSink(self):
382385

383386
def testVectorDestination(self):
384387
param = QgsProcessingParameterVectorDestination('test')
385-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
388+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
386389
panel = DestinationSelectionPanel(param, alg)
387390

388391
panel.setValue('''ogr:dbname='/me/a.gpkg' table="d" (geom) sql=''')
@@ -412,7 +415,7 @@ def testVectorDestination(self):
412415

413416
def testRasterDestination(self):
414417
param = QgsProcessingParameterRasterDestination('test')
415-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
418+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
416419
panel = DestinationSelectionPanel(param, alg)
417420

418421
panel.setValue('/home/me/test.tif')
@@ -430,7 +433,7 @@ def testRasterDestination(self):
430433

431434
def testFolderDestination(self):
432435
param = QgsProcessingParameterFolderDestination('test')
433-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
436+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
434437
panel = DestinationSelectionPanel(param, alg)
435438

436439
panel.setValue('/home/me/test.tif')
@@ -444,7 +447,7 @@ def testFolderDestination(self):
444447

445448
def testFileDestination(self):
446449
param = QgsProcessingParameterFileDestination('test')
447-
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
450+
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
448451
panel = DestinationSelectionPanel(param, alg)
449452

450453
panel.setValue('/home/me/test.tif')

0 commit comments

Comments
 (0)
Please sign in to comment.