44import pathlib
55import re
66import sys
7+ import types
78import typing
89from functools import cmp_to_key
910from io import StringIO
@@ -134,6 +135,10 @@ def __getitem__(self, params):
134135 [
135136 pytest .param (str , "builtins" , "str" , (), id = "str" ),
136137 pytest .param (None , "builtins" , "None" , (), id = "None" ),
138+ pytest .param (ModuleType , "types" , "ModuleType" , (), id = "ModuleType" ),
139+ pytest .param (FunctionType , "types" , "FunctionType" , (), id = "FunctionType" ),
140+ pytest .param (types .CodeType , "types" , "CodeType" , (), id = "CodeType" ),
141+ pytest .param (types .CoroutineType , "types" , "CoroutineType" , (), id = "CoroutineType" ),
137142 pytest .param (Any , "typing" , "Any" , (), id = "Any" ),
138143 pytest .param (AnyStr , "typing" , "AnyStr" , (), id = "AnyStr" ),
139144 pytest .param (Dict , "typing" , "Dict" , (), id = "Dict" ),
@@ -170,9 +175,10 @@ def __getitem__(self, params):
170175 ],
171176)
172177def test_parse_annotation (annotation : Any , module : str , class_name : str , args : tuple [Any , ...]) -> None :
173- assert get_annotation_module (annotation ) == module
174- assert get_annotation_class_name (annotation , module ) == class_name
175- assert get_annotation_args (annotation , module , class_name ) == args
178+ got_mod = get_annotation_module (annotation )
179+ got_cls = get_annotation_class_name (annotation , module )
180+ got_args = get_annotation_args (annotation , module , class_name )
181+ assert (got_mod , got_cls , got_args ) == (module , class_name , args )
176182
177183
178184@pytest .mark .parametrize (
@@ -181,6 +187,8 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
181187 (str , ":py:class:`str`" ),
182188 (int , ":py:class:`int`" ),
183189 (StringIO , ":py:class:`~io.StringIO`" ),
190+ (FunctionType , ":py:class:`~types.FunctionType`" ),
191+ (ModuleType , ":py:class:`~types.ModuleType`" ),
184192 (type (None ), ":py:obj:`None`" ),
185193 (type , ":py:class:`type`" ),
186194 (collections .abc .Callable , ":py:class:`~collections.abc.Callable`" ),
0 commit comments