diff options
author | Guido van Rossum <guido@python.org> | 2016-10-29 23:05:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-10-29 23:05:26 (GMT) |
commit | 62fe1bb983084c74fd8e7028412d0130a14568f3 (patch) | |
tree | 89fe564d149458b7060cdea02e19f966fbe34a4c /Lib/test/test_typing.py | |
parent | b7dedc89f1ec476352f3678d0c55252159da27df (diff) | |
download | cpython-62fe1bb983084c74fd8e7028412d0130a14568f3.zip cpython-62fe1bb983084c74fd8e7028412d0130a14568f3.tar.gz cpython-62fe1bb983084c74fd8e7028412d0130a14568f3.tar.bz2 |
Issue #28556: updates to typing.py (add Coroutine, prohibit Generic[T]())
Diffstat (limited to 'Lib/test/test_typing.py')
-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 b50f366..7a5b415 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) |