summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-05-24 23:38:22 (GMT)
committerGuido van Rossum <guido@python.org>2016-05-24 23:38:22 (GMT)
commiteb9aca3c071aab925831a389ab26816c170dc159 (patch)
tree0c505676afe12a4cd5b83e3d4bd7e4301d8597cb /Lib/test/test_typing.py
parent5a093c158abda2c1e212c8ccc3cebba30a2a0596 (diff)
downloadcpython-eb9aca3c071aab925831a389ab26816c170dc159.zip
cpython-eb9aca3c071aab925831a389ab26816c170dc159.tar.gz
cpython-eb9aca3c071aab925831a389ab26816c170dc159.tar.bz2
Added Type[C] implementation to typing.py.
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py28
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):