mirror of https://github.com/python/cpython
Issue #28482: Skip a few test_typing tests if asyncio unavailable
This commit is contained in:
parent
e8a6045fea
commit
ac353dfa14
|
@ -1116,9 +1116,9 @@ class OverloadTests(BaseTestCase):
|
||||||
blah()
|
blah()
|
||||||
|
|
||||||
|
|
||||||
PY35 = sys.version_info[:2] >= (3, 5)
|
ASYNCIO = sys.version_info[:2] >= (3, 5)
|
||||||
|
|
||||||
PY35_TESTS = """
|
ASYNCIO_TESTS = """
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
T_a = TypeVar('T')
|
T_a = TypeVar('T')
|
||||||
|
@ -1149,8 +1149,11 @@ class AsyncIteratorWrapper(typing.AsyncIterator[T_a]):
|
||||||
raise StopAsyncIteration
|
raise StopAsyncIteration
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if PY35:
|
if ASYNCIO:
|
||||||
exec(PY35_TESTS)
|
try:
|
||||||
|
exec(ASYNCIO_TESTS)
|
||||||
|
except ImportError:
|
||||||
|
ASYNCIO = False
|
||||||
|
|
||||||
PY36 = sys.version_info[:2] >= (3, 6)
|
PY36 = sys.version_info[:2] >= (3, 6)
|
||||||
|
|
||||||
|
@ -1253,7 +1256,7 @@ class CollectionsAbcTests(BaseTestCase):
|
||||||
self.assertIsInstance(it, typing.Iterator)
|
self.assertIsInstance(it, typing.Iterator)
|
||||||
self.assertNotIsInstance(42, 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):
|
def test_awaitable(self):
|
||||||
ns = {}
|
ns = {}
|
||||||
exec(
|
exec(
|
||||||
|
@ -1266,7 +1269,7 @@ class CollectionsAbcTests(BaseTestCase):
|
||||||
self.assertNotIsInstance(foo, typing.Awaitable)
|
self.assertNotIsInstance(foo, typing.Awaitable)
|
||||||
g.send(None) # Run foo() till completion, to avoid warning.
|
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):
|
def test_async_iterable(self):
|
||||||
base_it = range(10) # type: Iterator[int]
|
base_it = range(10) # type: Iterator[int]
|
||||||
it = AsyncIteratorWrapper(base_it)
|
it = AsyncIteratorWrapper(base_it)
|
||||||
|
@ -1274,7 +1277,7 @@ class CollectionsAbcTests(BaseTestCase):
|
||||||
self.assertIsInstance(it, typing.AsyncIterable)
|
self.assertIsInstance(it, typing.AsyncIterable)
|
||||||
self.assertNotIsInstance(42, 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):
|
def test_async_iterator(self):
|
||||||
base_it = range(10) # type: Iterator[int]
|
base_it = range(10) # type: Iterator[int]
|
||||||
it = AsyncIteratorWrapper(base_it)
|
it = AsyncIteratorWrapper(base_it)
|
||||||
|
|
Loading…
Reference in New Issue