diff options
author | Guido van Rossum <guido@python.org> | 2016-10-29 16:05:27 -0700 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-10-29 16:05:27 -0700 |
commit | ab5cf4da4e57fd317e6c4baaaa1d679c0ee9ef08 (patch) | |
tree | c8d0242ff257eea88ab34e5623a4a8e9903f8bc6 /Lib/test | |
parent | c6c1c6ef79b359ca4f6b30c0c91514e9ea486b9c (diff) | |
parent | 62fe1bb983084c74fd8e7028412d0130a14568f3 (diff) | |
download | cpython-git-ab5cf4da4e57fd317e6c4baaaa1d679c0ee9ef08.tar.gz |
Issue #28556: updates to typing.py (add Coroutine, prohibit Generic[T]()) (3.5->3.6)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_typing.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index b50f36679d..7a5b415bae 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -517,6 +517,9 @@ class GenericTests(BaseTestCase): Y[str, str] def test_generic_errors(self): + T = TypeVar('T') + with self.assertRaises(TypeError): + Generic[T]() with self.assertRaises(TypeError): isinstance([], List[int]) with self.assertRaises(TypeError): @@ -1255,7 +1258,7 @@ ASYNCIO = sys.version_info[:2] >= (3, 5) ASYNCIO_TESTS = """ import asyncio -T_a = TypeVar('T') +T_a = TypeVar('T_a') class AwaitableWrapper(typing.Awaitable[T_a]): @@ -1404,6 +1407,24 @@ class CollectionsAbcTests(BaseTestCase): g.send(None) # Run foo() till completion, to avoid warning. @skipUnless(ASYNCIO, 'Python 3.5 and multithreading required') + def test_coroutine(self): + ns = {} + exec( + "async def foo():\n" + " return\n", + globals(), ns) + foo = ns['foo'] + g = foo() + self.assertIsInstance(g, typing.Coroutine) + with self.assertRaises(TypeError): + isinstance(g, typing.Coroutine[int]) + self.assertNotIsInstance(foo, typing.Coroutine) + try: + g.send(None) + except StopIteration: + pass + + @skipUnless(ASYNCIO, 'Python 3.5 and multithreading required') def test_async_iterable(self): base_it = range(10) # type: Iterator[int] it = AsyncIteratorWrapper(base_it) |