diff options
author | Guido van Rossum <guido@python.org> | 2016-10-29 16:05:28 -0700 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-10-29 16:05:28 -0700 |
commit | 7ca671532cee6e8ed80dbd6e461f1de50ee93a3b (patch) | |
tree | fdcba76f80af421e89c74e7f559ce97e19f89b45 /Lib/test | |
parent | fd274c47aa99fc0add7457a0ee4f3d4228bab1fe (diff) | |
parent | ab5cf4da4e57fd317e6c4baaaa1d679c0ee9ef08 (diff) | |
download | cpython-git-7ca671532cee6e8ed80dbd6e461f1de50ee93a3b.tar.gz |
Issue #28556: updates to typing.py (add Coroutine, prohibit Generic[T]()) (3.6->3.7)
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) |