diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-18 22:29:03 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-21 23:04:42 +0900 |
commit | 46a7ea7adabf5ff306a936c080ce52052acaf96d (patch) | |
tree | 1f00fb20e8e01b8a92d0b6da817482afb8d1be0f /tests/test_util_typing.py | |
parent | 93d6c212f7cbab727db7a643d0092837979bbaa4 (diff) | |
download | sphinx-git-46a7ea7adabf5ff306a936c080ce52052acaf96d.tar.gz |
Add NewType support to typing.stringify() and restify()
Diffstat (limited to 'tests/test_util_typing.py')
-rw-r--r-- | tests/test_util_typing.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/test_util_typing.py b/tests/test_util_typing.py index c81cdaba2..882c652cc 100644 --- a/tests/test_util_typing.py +++ b/tests/test_util_typing.py @@ -10,7 +10,8 @@ import sys from numbers import Integral -from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, TypeVar, Union +from typing import (Any, Callable, Dict, Generator, List, NewType, Optional, Tuple, TypeVar, + Union) import pytest @@ -26,6 +27,7 @@ class MyClass2(MyClass1): T = TypeVar('T') +MyInt = NewType('MyInt', int) class MyList(List[T]): @@ -92,6 +94,7 @@ def test_restify_type_hints_typevars(): assert restify(T_co) == ":obj:`tests.test_util_typing.T_co`" assert restify(T_contra) == ":obj:`tests.test_util_typing.T_contra`" assert restify(List[T]) == ":class:`List`\\ [:obj:`tests.test_util_typing.T`]" + assert restify(MyInt) == ":class:`MyInt`" def test_restify_type_hints_custom_class(): @@ -179,6 +182,7 @@ def test_stringify_type_hints_typevars(): assert stringify(T_co) == "T_co" assert stringify(T_contra) == "T_contra" assert stringify(List[T]) == "List[T]" + assert stringify(MyInt) == "MyInt" def test_stringify_type_hints_custom_class(): |