Skip to content

Commit

Permalink
added test to catch type error when optional outputs with file templa…
Browse files Browse the repository at this point in the history
…tes being set to False
  • Loading branch information
tclose committed Sep 28, 2023
1 parent 0e3d33c commit bbc2769
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pydra/engine/tests/test_shelltask.py
Original file line number Diff line number Diff line change
Expand Up @@ -4347,6 +4347,57 @@ def change_name(file):
# res = shelly(plugin="cf")


def test_shell_cmd_optional_output_file(tmp_path):
"""
Test to see that 'unused' doesn't complain about not having an output passed to it
"""
my_cp_spec = SpecInfo(
name="Input",
fields=[
(
"input",
attr.ib(
type=File, metadata={"argstr": "", "help_string": "input file"}
),
),
(
"output",
attr.ib(
type=Path,
metadata={
"argstr": "",
"output_file_template": "out.txt",
"help_string": "output file",
},
),
),
(
"unused",
attr.ib(
type=ty.Union[Path, bool],
default=False,
metadata={
"argstr": "--not-used",
"output_file_template": "out.txt",
"help_string": "dummy output",
},
),
),
],
bases=(ShellSpec,),
)

my_cp = ShellCommandTask(
name="my_cp",
executable="cp",
input_spec=my_cp_spec,
)
file1 = tmp_path / "file1.txt"
file1.write_text("foo")
result = my_cp(input=file1, unused=False)
assert result.output.output.read_text() == "foo"


def test_shell_cmd_non_existing_outputs_1(tmp_path):
"""Checking that non existing output files do not return a phantom path,
but return NOTHING instead"""
Expand Down

0 comments on commit bbc2769

Please sign in to comment.