@@ -2938,7 +2938,9 @@ def blah():
2938
2938
blah ()
2939
2939
2940
2940
2941
- ASYNCIO_TESTS = """
2941
+ # Definitions needed for features introduced in Python 3.6
2942
+
2943
+ from test import ann_module , ann_module2 , ann_module3 , ann_module5 , ann_module6
2942
2944
import asyncio
2943
2945
2944
2946
T_a = TypeVar ('T_a' )
@@ -2972,19 +2974,6 @@ async def __aenter__(self) -> int:
2972
2974
return 42
2973
2975
async def __aexit__ (self , etype , eval , tb ):
2974
2976
return None
2975
- """
2976
-
2977
- try :
2978
- exec (ASYNCIO_TESTS )
2979
- except ImportError :
2980
- ASYNCIO = False # multithreading is not enabled
2981
- else :
2982
- ASYNCIO = True
2983
-
2984
- # Definitions needed for features introduced in Python 3.6
2985
-
2986
- from test import ann_module , ann_module2 , ann_module3 , ann_module5 , ann_module6
2987
- from typing import AsyncContextManager
2988
2977
2989
2978
class A :
2990
2979
y : float
@@ -3044,7 +3033,7 @@ class HasForeignBaseClass(mod_generics_cache.A):
3044
3033
some_xrepr : 'XRepr'
3045
3034
other_a : 'mod_generics_cache.A'
3046
3035
3047
- async def g_with (am : AsyncContextManager [int ]):
3036
+ async def g_with (am : typing . AsyncContextManager [int ]):
3048
3037
x : int
3049
3038
async with am as x :
3050
3039
return x
@@ -3386,7 +3375,6 @@ def test_iterator(self):
3386
3375
self .assertIsInstance (it , typing .Iterator )
3387
3376
self .assertNotIsInstance (42 , typing .Iterator )
3388
3377
3389
- @skipUnless (ASYNCIO , 'Python 3.5 and multithreading required' )
3390
3378
def test_awaitable (self ):
3391
3379
ns = {}
3392
3380
exec (
@@ -3399,7 +3387,6 @@ def test_awaitable(self):
3399
3387
self .assertNotIsInstance (foo , typing .Awaitable )
3400
3388
g .send (None ) # Run foo() till completion, to avoid warning.
3401
3389
3402
- @skipUnless (ASYNCIO , 'Python 3.5 and multithreading required' )
3403
3390
def test_coroutine (self ):
3404
3391
ns = {}
3405
3392
exec (
@@ -3417,15 +3404,13 @@ def test_coroutine(self):
3417
3404
except StopIteration :
3418
3405
pass
3419
3406
3420
- @skipUnless (ASYNCIO , 'Python 3.5 and multithreading required' )
3421
3407
def test_async_iterable (self ):
3422
3408
base_it = range (10 ) # type: Iterator[int]
3423
3409
it = AsyncIteratorWrapper (base_it )
3424
3410
self .assertIsInstance (it , typing .AsyncIterable )
3425
3411
self .assertIsInstance (it , typing .AsyncIterable )
3426
3412
self .assertNotIsInstance (42 , typing .AsyncIterable )
3427
3413
3428
- @skipUnless (ASYNCIO , 'Python 3.5 and multithreading required' )
3429
3414
def test_async_iterator (self ):
3430
3415
base_it = range (10 ) # type: Iterator[int]
3431
3416
it = AsyncIteratorWrapper (base_it )
@@ -3580,15 +3565,13 @@ class MyOrdDict(typing.OrderedDict[str, int]):
3580
3565
self .assertIsSubclass (MyOrdDict , collections .OrderedDict )
3581
3566
self .assertNotIsSubclass (collections .OrderedDict , MyOrdDict )
3582
3567
3583
- @skipUnless (sys .version_info >= (3 , 3 ), 'ChainMap was added in 3.3' )
3584
3568
def test_chainmap_instantiation (self ):
3585
3569
self .assertIs (type (typing .ChainMap ()), collections .ChainMap )
3586
3570
self .assertIs (type (typing .ChainMap [KT , VT ]()), collections .ChainMap )
3587
3571
self .assertIs (type (typing .ChainMap [str , int ]()), collections .ChainMap )
3588
3572
class CM (typing .ChainMap [KT , VT ]): ...
3589
3573
self .assertIs (type (CM [int , str ]()), CM )
3590
3574
3591
- @skipUnless (sys .version_info >= (3 , 3 ), 'ChainMap was added in 3.3' )
3592
3575
def test_chainmap_subclass (self ):
3593
3576
3594
3577
class MyChainMap (typing .ChainMap [str , int ]):
@@ -3852,7 +3835,6 @@ def manager():
3852
3835
self .assertIsInstance (cm , typing .ContextManager )
3853
3836
self .assertNotIsInstance (42 , typing .ContextManager )
3854
3837
3855
- @skipUnless (ASYNCIO , 'Python 3.5 required' )
3856
3838
def test_async_contextmanager (self ):
3857
3839
class NotACM :
3858
3840
pass
0 commit comments