mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-06 00:03:16 -05:00
Follow up 6a17a60ae2 - Fix error when passing usesgeometry to qgsfunction
This commit is contained in:
parent
c8d874889f
commit
d9042f590f
@ -84,6 +84,5 @@ def qgsfunction(args, group, **kwargs):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def wrapper(func):
|
def wrapper(func):
|
||||||
usesgeometry = kwargs.get('usesgeometry', False)
|
return register_function(func, args, group, **kwargs)
|
||||||
return register_function(func, args, group, usesgeometry, **kwargs)
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
@ -31,6 +31,10 @@ class TestQgsExpressionCustomFunctions(TestCase):
|
|||||||
def sqrt(values, feature, parent):
|
def sqrt(values, feature, parent):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@qgsfunction(1, 'testing', register=False, usesgeometry=True)
|
||||||
|
def geomtest(values, feature, parent):
|
||||||
|
pass
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
QgsExpression.unregisterFunction('testfun')
|
QgsExpression.unregisterFunction('testfun')
|
||||||
|
|
||||||
@ -79,6 +83,10 @@ class TestQgsExpressionCustomFunctions(TestCase):
|
|||||||
success = QgsExpression.registerFunction(self.sqrt)
|
success = QgsExpression.registerFunction(self.sqrt)
|
||||||
self.assertFalse(success)
|
self.assertFalse(success)
|
||||||
|
|
||||||
|
def testCanRegisterGeometryFunction(self):
|
||||||
|
success = QgsExpression.registerFunction(self.geomtest)
|
||||||
|
self.assertTrue(success)
|
||||||
|
|
||||||
def testCantOverrideBuiltinsWithUnregister(self):
|
def testCantOverrideBuiltinsWithUnregister(self):
|
||||||
success = QgsExpression.unregisterFunction("sqrt")
|
success = QgsExpression.unregisterFunction("sqrt")
|
||||||
self.assertFalse(success)
|
self.assertFalse(success)
|
||||||
@ -98,7 +106,7 @@ class TestQgsExpressionCustomFunctions(TestCase):
|
|||||||
expressions = {
|
expressions = {
|
||||||
"'test' /* comment */": 'test',
|
"'test' /* comment */": 'test',
|
||||||
"/* comment */'test'": 'test',
|
"/* comment */'test'": 'test',
|
||||||
"/* comment */'test*/'": 'test*/',
|
"/* comment */'test*/'": 'test*/',
|
||||||
"/** comment */'test*/'": 'test*/',
|
"/** comment */'test*/'": 'test*/',
|
||||||
"/* comment **/'test*/' /* comment */": 'test*/',
|
"/* comment **/'test*/' /* comment */": 'test*/',
|
||||||
"'test/*'/* comment */": 'test/*',
|
"'test/*'/* comment */": 'test/*',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user