Skip to content

Commit

Permalink
Merge pull request #62 from atlanticwave-sdx/increase-unittests
Browse files Browse the repository at this point in the history
XS✔ ◾ Increase unit test for utils
  • Loading branch information
gretelliz authored Sep 11, 2024
2 parents 13d7e53 + eba6dd0 commit ebf5765
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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):
"""
Expand All @@ -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):
"""
Expand All @@ -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):
"""
Expand Down

0 comments on commit ebf5765

Please sign in to comment.