summaryrefslogtreecommitdiff
path: root/tests/test_util_typing.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-07-20 01:14:12 +0900
committerGitHub <noreply@github.com>2021-07-20 01:14:12 +0900
commitf9941b9402821de2d60c1e94f9ac5cf0379640d0 (patch)
treeffcb578bd656fae5fff0285bec78b15774be182d /tests/test_util_typing.py
parent362f36d35ddc103198ecdf16e4958040f9d35c9d (diff)
parent451811c40cd9918213a13591a6b8dcaab4287ed5 (diff)
downloadsphinx-git-f9941b9402821de2d60c1e94f9ac5cf0379640d0.tar.gz
Merge pull request #9464 from Gobot1234/4.x
Add support for PEP 585 generics
Diffstat (limited to 'tests/test_util_typing.py')
-rw-r--r--tests/test_util_typing.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_util_typing.py b/tests/test_util_typing.py
index d0c511d25..04125a73a 100644
--- a/tests/test_util_typing.py
+++ b/tests/test_util_typing.py
@@ -176,6 +176,18 @@ def test_stringify_type_hints_containers():
@pytest.mark.skipif(sys.version_info < (3, 9), reason='python 3.9+ is required.')
+def test_stringify_type_hints_pep_585():
+ assert stringify(list[int]) == "list[int]"
+ assert stringify(list[str]) == "list[str]"
+ assert stringify(dict[str, float]) == "dict[str, float]"
+ assert stringify(tuple[str, str, str]) == "tuple[str, str, str]"
+ assert stringify(tuple[str, ...]) == "tuple[str, ...]"
+ assert stringify(tuple[()]) == "tuple[()]"
+ assert stringify(list[dict[str, tuple]]) == "list[dict[str, tuple]]"
+ assert stringify(type[int]) == "type[int]"
+
+
+@pytest.mark.skipif(sys.version_info < (3, 9), reason='python 3.9+ is required.')
def test_stringify_Annotated():
from typing import Annotated # type: ignore
assert stringify(Annotated[str, "foo", "bar"]) == "str" # NOQA