Navigation Menu

Skip to content


Add test that python exception is caught when executing an alg
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 23, 2017
1 parent eb39fb0 commit a8cdde5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions python/plugins/processing/tests/
Expand Up @@ -30,7 +30,28 @@
import nose2
import shutil

from qgis.core import (QgsProcessingAlgorithm,
from qgis.testing import start_app, unittest
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from import createContext

class TestAlg(QgsProcessingAlgorithm):

def __init__(self):

def name(self):
return 'testalg'

def displayName(self):
return 'testalg'

def processAlgorithm(self, parameters, context, feedback):
raise GeoAlgorithmExecutionException('Exception while processing'))
return {}

class TestQgisAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
Expand All @@ -52,6 +73,17 @@ def tearDownClass(cls):
def test_definition_file(self):
return 'qgis_algorithm_tests.yaml'

def testProcessingException(self):
Test that Python exception is caught when running an alg

alg = TestAlg()
context = createContext()
feedback = QgsProcessingFeedback()
results, ok ={}, context, feedback)

if __name__ == '__main__':
2 changes: 1 addition & 1 deletion python/plugins/processing/tools/
Expand Up @@ -65,7 +65,7 @@

def createContext(feedback):
def createContext(feedback=None):
Creates a default processing context
Expand Down

0 comments on commit a8cdde5

Please sign in to comment.