diff --git a/topology-conversion/tests/test_unit/utils/test_typing_utils.py b/topology-conversion/tests/test_unit/utils/test_typing_utils.py index 331f665..6777ed6 100644 --- a/topology-conversion/tests/test_unit/utils/test_typing_utils.py +++ b/topology-conversion/tests/test_unit/utils/test_typing_utils.py @@ -1,11 +1,15 @@ import pytest -from typing import List, Dict +from typing import List, Dict, Generic, TypeVar from utils.typing_utils import is_generic, is_dict, is_list +# Define type variables for testing +T = TypeVar('T') + @pytest.mark.parametrize("klass, expected", [ (List[int], True), # Test if List[int] is recognized as a generic class (Dict[str, int], True), # Test if Dict[str, int] is recognized as a generic class (int, False), # Test if int is not recognized as a generic class + (Generic[T], True), # Test if Generic[T] is recognized as a generic class ]) def test_is_generic(klass, expected): """ @@ -20,6 +24,7 @@ def test_is_generic(klass, expected): @pytest.mark.parametrize("klass, expected", [ (Dict[str, int], True), # Test if Dict[str, int] is recognized as a dict (List[int], False), # Test if List[int] is not recognized as a dict + (Dict[str, Dict[str, int]], True), # Test nested dictionary ]) def test_is_dict(klass, expected): """ @@ -34,6 +39,7 @@ def test_is_dict(klass, expected): @pytest.mark.parametrize("klass, expected", [ (List[int], True), # Test if List[int] is recognized as a list (Dict[str, int], False), # Test if Dict[str, int] is not recognized as a list + (List[List[int]], True), # Test nested list ]) def test_is_list(klass, expected): """