Skip to content
Permalink
Browse files

Fix test

  • Loading branch information
nyalldawson committed Jul 2, 2018
1 parent 2cc9bc8 commit f43adf7a8b9d9f65a3e78b26e500fba6c52d87a9
Showing with 15 additions and 4 deletions.
  1. +1 −1 python/plugins/processing/gui/NumberInputPanel.py
  2. +14 −3 python/plugins/processing/tests/GuiTest.py
@@ -224,7 +224,7 @@ def getLayerFromValue(self, value):
value, ok = value.source.valueAsString(context.expressionContext())
if isinstance(value, str):
value = QgsProcessingUtils.mapLayerFromString(value, context)
if value is None:
if value is None or not isinstance(value, QgsMapLayer):
return None

# need to return layer with ownership - otherwise layer may be deleted when context
@@ -29,7 +29,8 @@
from qgis.core import (QgsApplication,
QgsCoordinateReferenceSystem,
QgsProcessingParameterMatrix,
QgsVectorLayer)
QgsVectorLayer,
QgsProject)
from qgis.analysis import QgsNativeAlgorithms

from processing.gui.AlgorithmDialog import AlgorithmDialog
@@ -152,11 +153,21 @@ def testDistance(self):
widget.setUnitParameterValue(vl)
self.assertEqual(widget.label.text(), 'meters')
self.assertFalse(widget.warning_label.isVisible())
vl = QgsVectorLayer("Polygon?crs=epsg:4326&field=pk:int", "vl", "memory")
widget.setUnitParameterValue(vl)
vl2 = QgsVectorLayer("Polygon?crs=epsg:4326&field=pk:int", "vl", "memory")
widget.setUnitParameterValue(vl2)
self.assertEqual(widget.label.text(), 'degrees')
self.assertTrue(widget.warning_label.isVisible())

# unresolvable values
widget.setUnitParameterValue(vl.id())
self.assertEqual(widget.label.text(), '<unknown>')
self.assertFalse(widget.warning_label.isVisible())
# resolvable text value
QgsProject.instance().addMapLayer(vl)
widget.setUnitParameterValue(vl.id())
self.assertEqual(widget.label.text(), 'meters')
self.assertFalse(widget.warning_label.isVisible())

widget.deleteLater()

def testMatrix(self):

0 comments on commit f43adf7

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