Commit 9d1cccd1 authored by mvdbeek's avatar mvdbeek
Browse files

Cast to None for optional params if not comparing strings

parent 20e2a49d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -83,8 +83,11 @@ class InputValueWrapper(ToolParameterValueWrapper):
        if self.input.type == 'boolean' and isinstance(other, string_types):
            return str(self)
        # For backward compatibility, allow `$wrapper != ""` for optional non-text param
        if self.input.optional and self.value is None and self.input.type != 'boolean':
        if self.input.optional and self.value is None:
            if isinstance(other, string_types):
                return str(self)
            else:
                return None
        cast = {
            'text': str,
            'integer': int,
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ def test_input_value_wrapper_comparison_optional(tool):
    wrapper = valuewrapper(tool, None, 'integer', optional=True)
    assert wrapper != 1
    assert str(wrapper) == ""
    assert wrapper == None  # noqa: E711
    wrapper = valuewrapper(tool, None, "boolean")
    assert bool(wrapper) is False, wrapper
    assert str(wrapper) == 'falsevalue'