summaryrefslogtreecommitdiff
path: root/tests/test_util_typing.py
diff options
context:
space:
mode:
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 d85eb0849..d3672f2cc 100644
--- a/tests/test_util_typing.py
+++ b/tests/test_util_typing.py
@@ -133,6 +133,12 @@ def test_restify_type_ForwardRef():
assert restify(ForwardRef("myint")) == ":class:`myint`"
+@pytest.mark.skipif(sys.version_info < (3, 8), reason='python 3.8+ is required.')
+def test_restify_type_Literal():
+ from typing import Literal # type: ignore
+ assert restify(Literal[1, "2", "\r"]) == ":obj:`~typing.Literal`\\ [1, '2', '\\r']"
+
+
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
def test_restify_type_union_operator():
assert restify(int | None) == "Optional[:class:`int`]" # type: ignore
@@ -237,6 +243,12 @@ def test_stringify_type_hints_alias():
assert stringify(MyTuple) == "Tuple[str, str]" # type: ignore
+@pytest.mark.skipif(sys.version_info < (3, 8), reason='python 3.8+ is required.')
+def test_stringify_type_Literal():
+ from typing import Literal # type: ignore
+ assert stringify(Literal[1, "2", "\r"]) == "Literal[1, '2', '\\r']"
+
+
@pytest.mark.skipif(sys.version_info < (3, 10), reason='python 3.10+ is required.')
def test_stringify_type_union_operator():
assert stringify(int | None) == "Optional[int]" # type: ignore