From d9042f590f003cfdb25f857ccc38b0b7ff625522 Mon Sep 17 00:00:00 2001 From: Nathan Woodrow Date: Sat, 10 Jan 2015 10:43:12 +1000 Subject: [PATCH] Follow up 6a17a60ae2 - Fix error when passing usesgeometry to qgsfunction --- python/core/__init__.py | 3 +-- tests/src/python/test_qgsexpression.py | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/python/core/__init__.py b/python/core/__init__.py index 58da471f94a..23026490b21 100644 --- a/python/core/__init__.py +++ b/python/core/__init__.py @@ -84,6 +84,5 @@ def qgsfunction(args, group, **kwargs): """ def wrapper(func): - usesgeometry = kwargs.get('usesgeometry', False) - return register_function(func, args, group, usesgeometry, **kwargs) + return register_function(func, args, group, **kwargs) return wrapper diff --git a/tests/src/python/test_qgsexpression.py b/tests/src/python/test_qgsexpression.py index 6878b688b96..2787e904c84 100644 --- a/tests/src/python/test_qgsexpression.py +++ b/tests/src/python/test_qgsexpression.py @@ -31,6 +31,10 @@ class TestQgsExpressionCustomFunctions(TestCase): def sqrt(values, feature, parent): pass + @qgsfunction(1, 'testing', register=False, usesgeometry=True) + def geomtest(values, feature, parent): + pass + def tearDown(self): QgsExpression.unregisterFunction('testfun') @@ -79,6 +83,10 @@ class TestQgsExpressionCustomFunctions(TestCase): success = QgsExpression.registerFunction(self.sqrt) self.assertFalse(success) + def testCanRegisterGeometryFunction(self): + success = QgsExpression.registerFunction(self.geomtest) + self.assertTrue(success) + def testCantOverrideBuiltinsWithUnregister(self): success = QgsExpression.unregisterFunction("sqrt") self.assertFalse(success) @@ -98,7 +106,7 @@ class TestQgsExpressionCustomFunctions(TestCase): expressions = { "'test' /* comment */": 'test', "/* comment */'test'": 'test', - "/* comment */'test*/'": 'test*/', + "/* comment */'test*/'": 'test*/', "/** comment */'test*/'": 'test*/', "/* comment **/'test*/' /* comment */": 'test*/', "'test/*'/* comment */": 'test/*',