diff options
Diffstat (limited to 'Lib/test/test_typing.py')
| -rw-r--r-- | Lib/test/test_typing.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index f9e54b2..ade8a35 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -15,6 +15,7 @@ from typing import Generic from typing import cast from typing import get_type_hints from typing import no_type_check, no_type_check_decorator +from typing import Type from typing import NamedTuple from typing import IO, TextIO, BinaryIO from typing import Pattern, Match @@ -1373,6 +1374,33 @@ class OtherABCTests(BaseTestCase): self.assertNotIsInstance(42, typing.ContextManager) +class TypeTests(BaseTestCase): + + def test_type_basic(self): + + class User: pass + class BasicUser(User): pass + class ProUser(User): pass + + def new_user(user_class: Type[User]) -> User: + return user_class() + + joe = new_user(BasicUser) + + def test_type_typevar(self): + + class User: pass + class BasicUser(User): pass + class ProUser(User): pass + + U = TypeVar('U', bound=User) + + def new_user(user_class: Type[U]) -> U: + return user_class() + + joe = new_user(BasicUser) + + class NamedTupleTests(BaseTestCase): def test_basics(self): |
