Follow up 6a17a60ae2 - Fix error when passing usesgeometry to qgsfunction

This commit is contained in:
Nathan Woodrow 2015-01-10 10:43:12 +10:00
parent c8d874889f
commit d9042f590f
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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/*',