summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2016-05-24 23:39:23 (GMT)
committerGuido van Rossum <guido@dropbox.com>2016-05-24 23:39:23 (GMT)
commit70223d9b09edf4cacc8267bdd588c3265e039233 (patch)
tree03ecd4941a2b7b219379b12c9c498ce18179fec7 /Lib/test
parent80ac11d01e2ede7116e03f195ed254c0fde543fa (diff)
parenteb9aca3c071aab925831a389ab26816c170dc159 (diff)
downloadcpython-70223d9b09edf4cacc8267bdd588c3265e039233.zip
cpython-70223d9b09edf4cacc8267bdd588c3265e039233.tar.gz
cpython-70223d9b09edf4cacc8267bdd588c3265e039233.tar.bz2
Added Type[C] implementation to typing.py. (Merge 3.5->3.6)
Diffstat (limited to 'Lib/test')
-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):