diff --git a/cwltool/command_line_tool.py b/cwltool/command_line_tool.py index c4798c0b7..d249c0200 100644 --- a/cwltool/command_line_tool.py +++ b/cwltool/command_line_tool.py @@ -1498,9 +1498,9 @@ def collect_output( def recursively_insert(j_dict: Any, key: Any, val: Any) -> Any: """Recursively insert a value into any dictionary.""" - if isinstance(j_dict, List): + if isinstance(j_dict, MutableSequence): return [recursively_insert(x, key, val) for x in j_dict] - if isinstance(j_dict, Dict): + if isinstance(j_dict, MutableMapping): if j_dict.get("class") == "File": j_dict[key] = val else: diff --git a/tests/test_2D.py b/tests/test_2D.py index fafddef5a..952515f25 100644 --- a/tests/test_2D.py +++ b/tests/test_2D.py @@ -1,21 +1,19 @@ -import subprocess -import sys from pathlib import Path +import pytest +from .util import get_data, get_main_output -from .util import get_data - - -def test_output_2D_file_format() -> None: +@pytest.fixture(scope="session") +def test_output_2d_file_format(tmp_path_factory: pytest.TempPathFactory) -> None: """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"), - ] + tmp_path: Path = tmp_path_factory.mktemp("tmp") + # still need to create 'filename.txt' as it is needed in output_2D_file_format.cwl + _ = tmp_path / "filename.txt" + commands = [ + "--cachedir", + str(tmp_path / "foo"), # just so that the relative path of file works out + get_data("tests/output_2D_file_format.cwl")] + + error_code, _, stderr = get_main_output(commands) - assert subprocess.check_call(params) == 0 + assert error_code == 0, stderr