# HG changeset patch # Parent c445746d08461dc146afcb34116b8d2731da853d Skip typing tests when asyncio unavailable (multithreading is disabled) diff -r c445746d0846 -r f0bba8f53440 Lib/test/test_typing.py --- a/Lib/test/test_typing.py Wed Oct 19 19:37:20 2016 +0300 +++ b/Lib/test/test_typing.py Thu Oct 20 02:48:44 2016 +0000 @@ -1030,9 +1030,9 @@ blah() -PY35 = sys.version_info[:2] >= (3, 5) +ASYNCIO = sys.version_info[:2] >= (3, 5) -PY35_TESTS = """ +ASYNCIO_TESTS = """ import asyncio T_a = TypeVar('T') @@ -1063,8 +1063,11 @@ raise StopAsyncIteration """ -if PY35: - exec(PY35_TESTS) +if ASYNCIO: + try: + exec(ASYNCIO_TESTS) + except ImportError: + ASYNCIO = False PY36 = sys.version_info[:2] >= (3, 6) @@ -1167,7 +1170,7 @@ self.assertIsInstance(it, typing.Iterator) self.assertNotIsInstance(42, typing.Iterator) - @skipUnless(PY35, 'Python 3.5 required') + @skipUnless(ASYNCIO, 'Python 3.5 and multithreading required') def test_awaitable(self): ns = {} exec( @@ -1180,7 +1183,7 @@ self.assertNotIsInstance(foo, typing.Awaitable) g.send(None) # Run foo() till completion, to avoid warning. - @skipUnless(PY35, 'Python 3.5 required') + @skipUnless(ASYNCIO, 'Python 3.5 and multithreading required') def test_async_iterable(self): base_it = range(10) # type: Iterator[int] it = AsyncIteratorWrapper(base_it) @@ -1188,7 +1191,7 @@ self.assertIsInstance(it, typing.AsyncIterable) self.assertNotIsInstance(42, typing.AsyncIterable) - @skipUnless(PY35, 'Python 3.5 required') + @skipUnless(ASYNCIO, 'Python 3.5 and multithreading required') def test_async_iterator(self): base_it = range(10) # type: Iterator[int] it = AsyncIteratorWrapper(base_it)