Skip to content

Commit 29b952d

Browse files
volayanyalldawson
authored andcommitted
[processing] consider destination params as outputs when defining scripts
1 parent 519a30f commit 29b952d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

python/processing/algfactory.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ def has_outputs(self):
211211
"""
212212
True if this alg wrapper has outputs defined.
213213
"""
214-
return bool(self._outputs)
214+
dests = [p for p in self._inputs.values() if p.isDestination()]
215+
return bool(self._outputs) or bool(dests)
215216

216217
@property
217218
def has_inputs(self):

tests/src/python/test_processing_alg_decorator.py

+22
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ def testalg(instance, parameters, context, feedback, inputs):
3737
"""
3838

3939

40+
def define_new_no_outputs_but_sink_instead(newid=1):
41+
@alg(name=ARGNAME.format(newid), label=alg.tr("Test func"), group="unittest",
42+
group_label=alg.tr("Test label"))
43+
@alg.help(HELPSTRING.format(newid))
44+
@alg.input(type=alg.SOURCE, name="INPUT", label="Input layer")
45+
@alg.input(type=alg.DISTANCE, name="DISTANCE", label="Distance", default=30)
46+
@alg.input(type=alg.SINK, name="SINK", label="Output layer")
47+
def testalg(instance, parameters, context, feedback, inputs):
48+
"""
49+
Given a distance will split a line layer into segments of the distance
50+
"""
51+
52+
4053
def define_new_doc_string(newid=1):
4154
@alg(name=ARGNAME.format(newid), label=alg.tr("Test func"), group="unittest",
4255
group_label=alg.tr("Test label"))
@@ -75,6 +88,15 @@ def test_can_have_no_inputs(self):
7588
define_new_no_inputs()
7689

7790

91+
class AlgNoOutputsButSinkInstead(unittest.TestCase):
92+
93+
def setUp(self):
94+
cleanup()
95+
96+
def test_can_have_no_outputs_if_there_is_destination(self):
97+
define_new_no_outputs_but_sink_instead()
98+
99+
78100
class AlgInstanceTests(unittest.TestCase):
79101
"""
80102
Tests to check the createInstance method will work as expected.

0 commit comments

Comments
 (0)