|
7 | 7 | import tempfile
|
8 | 8 | import pytest
|
9 | 9 | from pydra import mark
|
10 |
| -from ...engine.specs import File, LazyOutField |
| 10 | +from ...engine.specs import File, LazyOutField, MultiInputObj |
11 | 11 | from ..typing import TypeParser
|
12 | 12 | from pydra import Workflow
|
13 | 13 | from fileformats.application import Json, Yaml, Xml
|
@@ -249,7 +249,7 @@ def test_type_check_fail3():
|
249 | 249 | def test_type_check_fail4():
|
250 | 250 | with pytest.raises(TypeError) as exc_info:
|
251 | 251 | TypeParser(ty.Sequence)(lz(ty.Dict[str, int]))
|
252 |
| - assert exc_info_matches(exc_info, "Cannot coerce <class 'dict'> into") |
| 252 | + assert exc_info_matches(exc_info, "Cannot coerce .*(d|D)ict.* into") |
253 | 253 |
|
254 | 254 |
|
255 | 255 | def test_type_check_fail5():
|
@@ -1043,3 +1043,63 @@ def test_type_is_instance11():
|
1043 | 1043 | @pytest.mark.skipif(sys.version_info < (3, 10), reason="No UnionType < Py3.10")
|
1044 | 1044 | def test_type_is_instance11a():
|
1045 | 1045 | assert not TypeParser.is_instance(None, int | str)
|
| 1046 | + |
| 1047 | + |
| 1048 | +def test_multi_input_obj_coerce1(): |
| 1049 | + assert TypeParser(MultiInputObj[str])("a") == ["a"] |
| 1050 | + |
| 1051 | + |
| 1052 | +def test_multi_input_obj_coerce2(): |
| 1053 | + assert TypeParser(MultiInputObj[str])(["a"]) == ["a"] |
| 1054 | + |
| 1055 | + |
| 1056 | +def test_multi_input_obj_coerce3(): |
| 1057 | + assert TypeParser(MultiInputObj[ty.List[str]])(["a"]) == [["a"]] |
| 1058 | + |
| 1059 | + |
| 1060 | +def test_multi_input_obj_coerce3a(): |
| 1061 | + assert TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])(["a"]) == [["a"]] |
| 1062 | + |
| 1063 | + |
| 1064 | +def test_multi_input_obj_coerce3b(): |
| 1065 | + assert TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])([["a"]]) == [["a"]] |
| 1066 | + |
| 1067 | + |
| 1068 | +def test_multi_input_obj_coerce4(): |
| 1069 | + assert TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])([1]) == [1] |
| 1070 | + |
| 1071 | + |
| 1072 | +def test_multi_input_obj_coerce4a(): |
| 1073 | + with pytest.raises(TypeError): |
| 1074 | + TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])([[1]]) |
| 1075 | + |
| 1076 | + |
| 1077 | +def test_multi_input_obj_check_type1(): |
| 1078 | + TypeParser(MultiInputObj[str])(lz(str)) |
| 1079 | + |
| 1080 | + |
| 1081 | +def test_multi_input_obj_check_type2(): |
| 1082 | + TypeParser(MultiInputObj[str])(lz(ty.List[str])) |
| 1083 | + |
| 1084 | + |
| 1085 | +def test_multi_input_obj_check_type3(): |
| 1086 | + TypeParser(MultiInputObj[ty.List[str]])(lz(ty.List[str])) |
| 1087 | + |
| 1088 | + |
| 1089 | +def test_multi_input_obj_check_type3a(): |
| 1090 | + TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])(lz(ty.List[str])) |
| 1091 | + |
| 1092 | + |
| 1093 | +def test_multi_input_obj_check_type3b(): |
| 1094 | + TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])(lz(ty.List[ty.List[str]])) |
| 1095 | + |
| 1096 | + |
| 1097 | +def test_multi_input_obj_check_type4(): |
| 1098 | + TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])(lz(ty.List[int])) |
| 1099 | + |
| 1100 | + |
| 1101 | +def test_multi_input_obj_check_type4a(): |
| 1102 | + with pytest.raises(TypeError): |
| 1103 | + TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])( |
| 1104 | + lz(ty.List[ty.List[int]]) |
| 1105 | + ) |
0 commit comments