@@ -1320,6 +1320,7 @@ def blah():
13201320
13211321
13221322ASYNCIO = sys .version_info [:2 ] >= (3 , 5 )
1323+ ASYNC_GENERATOR = sys .version_info [:2 ] >= (3 , 6 )
13231324
13241325ASYNCIO_TESTS = """
13251326import asyncio
@@ -1696,6 +1697,23 @@ def test_no_generator_instantiation(self):
16961697 with self .assertRaises (TypeError ):
16971698 typing .Generator [int , int , int ]()
16981699
1700+ @skipUnless (PY36 , 'Python 3.6 required' )
1701+ def test_async_generator (self ):
1702+ ns = {}
1703+ exec ("async def f():\n "
1704+ " yield 42\n " , globals (), ns )
1705+ g = ns ['f' ]()
1706+ self .assertIsSubclass (type (g ), typing .AsyncGenerator )
1707+
1708+ @skipUnless (PY36 , 'Python 3.6 required' )
1709+ def test_no_async_generator_instantiation (self ):
1710+ with self .assertRaises (TypeError ):
1711+ typing .AsyncGenerator ()
1712+ with self .assertRaises (TypeError ):
1713+ typing .AsyncGenerator [T , T ]()
1714+ with self .assertRaises (TypeError ):
1715+ typing .AsyncGenerator [int , int ]()
1716+
16991717 def test_subclassing (self ):
17001718
17011719 class MMA (typing .MutableMapping ):
@@ -1765,6 +1783,18 @@ def g(): yield 0
17651783 self .assertIsSubclass (G , collections .Iterable )
17661784 self .assertNotIsSubclass (type (g ), G )
17671785
1786+ @skipUnless (PY36 , 'Python 3.6 required' )
1787+ def test_subclassing_async_generator (self ):
1788+ class G (typing .AsyncGenerator [int , int ]): ...
1789+ ns = {}
1790+ exec ('async def g(): yield 0' , globals (), ns )
1791+ g = ns ['g' ]
1792+ self .assertIsSubclass (G , typing .AsyncGenerator )
1793+ self .assertIsSubclass (G , typing .AsyncIterable )
1794+ self .assertIsSubclass (G , collections .AsyncGenerator )
1795+ self .assertIsSubclass (G , collections .AsyncIterable )
1796+ self .assertNotIsSubclass (type (g ), G )
1797+
17681798 def test_subclassing_subclasshook (self ):
17691799
17701800 class Base (typing .Iterable ):
0 commit comments