Skip to content

Commit

Permalink
modify test2D to automate file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasu Jaganath committed Jul 9, 2024
1 parent 6f313a5 commit 6efcc8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cwltool/command_line_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,14 +1497,16 @@ def collect_output(
else:

def recursively_insert(j_dict: Any, key: Any, val: Any) -> Any:
"""Recursively inserts a value into any dictionaries"""
"""Recursively insert a value into any dictionary."""
if isinstance(j_dict, List):
return [recursively_insert(x, key, val) for x in j_dict]
if isinstance(j_dict, Dict):
if j_dict.get("class") == "File":
j_dict[key] = val
else:
return {x: recursively_insert(y, key, val) for x, y in j_dict.items()}
return {
x: recursively_insert(y, key, val) for x, y in j_dict.items()
}
return j_dict

result = recursively_insert(result, "format", format_field)
Expand Down
6 changes: 5 additions & 1 deletion tests/test_2D.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import subprocess
import sys
from pathlib import Path

from .util import get_data


def test_output_2D_file_format() -> None:
"""Test format tag for 2D output arrays."""
"""A simple test for format tag fix for 2D output arrays."""

Path("filename.txt").touch()
params = [
sys.executable,
"-m",
"cwltool",
"--cachedir", # just so that the relative path of file works out
"foo",
get_data("tests/output_2D_file_format.cwl"),
]

Expand Down

0 comments on commit 6efcc8e

Please sign in to comment.