Skip to content

Commit

Permalink
Update pydra/utils/tests/test_typing.py
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Markiewicz <[email protected]>
  • Loading branch information
tclose and effigies authored May 30, 2024
1 parent ca0833c commit ae0422a
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions pydra/utils/tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,28 +1039,19 @@ def test_type_is_instance11a():
assert not TypeParser.is_instance(None, int | str)


def test_multi_input_obj_coerce1():
assert TypeParser(MultiInputObj[str])("a") == ["a"]


def test_multi_input_obj_coerce2():
assert TypeParser(MultiInputObj[str])(["a"]) == ["a"]


def test_multi_input_obj_coerce3():
assert TypeParser(MultiInputObj[ty.List[str]])(["a"]) == [["a"]]


def test_multi_input_obj_coerce3a():
assert TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])(["a"]) == [["a"]]


def test_multi_input_obj_coerce3b():
assert TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])([["a"]]) == [["a"]]


def test_multi_input_obj_coerce4():
assert TypeParser(MultiInputObj[ty.Union[int, ty.List[str]]])([1]) == [1]
@pytest.mark.parametrize(
("typ", "obj", "result"),
[
(MultiInputObj[str], "a", ["a"]),
(MultiInputObj[str], ["a"], ["a"]),
(MultiInputObj[ty.List[str]], ["a"], [["a"]]),
(MultiInputObj[ty.Union[int, ty.List[str]]], ["a"], [["a"]]),
(MultiInputObj[ty.Union[int, ty.List[str]]], [["a"]], [["a"]]),
(MultiInputObj[ty.Union[int, ty.List[str]]], [1], [1]),
]
)
def test_multi_input_obj_coerce(typ, obj, result):
assert TypeParser(typ)(obj) == result


def test_multi_input_obj_coerce4a():
Expand Down

0 comments on commit ae0422a

Please sign in to comment.