diff --git a/tests/test_utils.py b/tests/test_utils.py index fbcdeaff410c..a3d4e473e87c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,5 @@ import json -from typing import Dict, List, Union, TypeVar +from typing import Dict, List, Union, Literal, TypeVar from utils import FakeMessage, FakeMessageSegment from nonebot.utils import ( @@ -24,6 +24,8 @@ def test_generic_check_issubclass(): assert generic_check_issubclass(int, (int, float)) assert not generic_check_issubclass(str, (int, float)) assert generic_check_issubclass(Union[int, float, None], (int, float)) + assert generic_check_issubclass(Literal[1, 2, 3], int) + assert not generic_check_issubclass(Literal[1, 2, "3"], int) assert generic_check_issubclass(List[int], list) assert generic_check_issubclass(Dict[str, int], dict) assert generic_check_issubclass(TypeVar("T", int, float), (int, float))