|
11 | 11 | from fileformats.generic import File
|
12 | 12 | from pydra.engine.lazy import LazyOutField
|
13 | 13 | from pydra.compose import workflow
|
14 |
| -from pydra.utils.typing import TypeParser, MultiInputObj |
| 14 | +from pydra.utils.typing import TypeParser, MultiInputObj, is_container |
15 | 15 | from fileformats.application import Json, Yaml, Xml
|
16 | 16 | from .utils import (
|
17 | 17 | GenericFuncTask,
|
@@ -866,6 +866,34 @@ def test_none_is_subclass2a():
|
866 | 866 | assert not TypeParser.is_subclass(None, int | float)
|
867 | 867 |
|
868 | 868 |
|
| 869 | +@pytest.mark.parametrize( |
| 870 | + ("type_",), |
| 871 | + [ |
| 872 | + (str,), |
| 873 | + (ty.List[int],), |
| 874 | + (ty.Tuple[int, ...],), |
| 875 | + (ty.Dict[str, int],), |
| 876 | + (ty.Union[ty.List[int], ty.Tuple[int, ...]],), |
| 877 | + (ty.Union[ty.List[int], ty.Dict[str, int]],), |
| 878 | + (ty.Union[ty.List[int], ty.Tuple[int, ...], ty.Dict[str, int]],), |
| 879 | + ], |
| 880 | +) |
| 881 | +def test_is_container(type_): |
| 882 | + assert is_container(type_) |
| 883 | + |
| 884 | + |
| 885 | +@pytest.mark.parametrize( |
| 886 | + ("type_",), |
| 887 | + [ |
| 888 | + (int,), |
| 889 | + (bool,), |
| 890 | + (ty.Union[bool, str],), |
| 891 | + ], |
| 892 | +) |
| 893 | +def test_is_not_container(type_): |
| 894 | + assert not is_container(type_) |
| 895 | + |
| 896 | + |
869 | 897 | @pytest.mark.skipif(
|
870 | 898 | sys.version_info < (3, 9), reason="Cannot subscript tuple in < Py3.9"
|
871 | 899 | )
|
|
0 commit comments