@@ -61,49 +61,59 @@ def some_generator():
6161 assert not is_awaitable (some_generator ())
6262
6363 def declines_a_coroutine_function ():
64- async def some_coroutine ():
64+ async def some_async_function ():
6565 return True # pragma: no cover
6666
67- assert not isawaitable (some_coroutine )
68- assert not is_awaitable (some_coroutine )
67+ assert not isawaitable (some_async_function )
68+ assert not is_awaitable (some_async_function )
6969
7070 @mark .asyncio
71- @mark .filterwarnings ("ignore:.* was never awaited:RuntimeWarning" )
7271 async def recognizes_a_coroutine_object ():
73- async def some_coroutine ():
74- return False # pragma: no cover
72+ async def some_async_function ():
73+ return True
74+
75+ some_coroutine = some_async_function ()
76+
77+ assert isawaitable (some_coroutine )
78+ assert is_awaitable (some_coroutine )
7579
76- assert isawaitable (some_coroutine ())
77- assert is_awaitable (some_coroutine ())
80+ assert await some_coroutine is True
7881
7982 @mark .filterwarnings ("ignore::Warning" ) # Deprecation and Runtime warnings
8083 @mark .skipif (
8184 python_version >= (3 , 11 ),
8285 reason = "Generator-based coroutines not supported any more since Python 3.11" ,
8386 )
84- def recognizes_an_old_style_coroutine (): # pragma: no cover
87+ async def recognizes_an_old_style_coroutine (): # pragma: no cover
8588 @asyncio .coroutine # type: ignore
86- def some_old_style_coroutine ():
87- yield False # pragma: no cover
89+ def some_function ():
90+ yield True
8891
89- assert is_awaitable (some_old_style_coroutine ())
90- assert is_awaitable (some_old_style_coroutine ())
92+ some_old_style_coroutine = some_function ()
93+ assert is_awaitable (some_old_style_coroutine )
94+ assert is_awaitable (some_old_style_coroutine )
9195
9296 @mark .asyncio
93- @mark .filterwarnings ("ignore:.* was never awaited:RuntimeWarning" )
9497 async def recognizes_a_future_object ():
95- async def some_coroutine ():
96- return False # pragma: no cover
98+ async def some_async_function ():
99+ return True
97100
98- some_future = asyncio .ensure_future (some_coroutine ())
101+ some_coroutine = some_async_function ()
102+ some_future = asyncio .ensure_future (some_coroutine )
99103
100104 assert is_awaitable (some_future )
101105 assert is_awaitable (some_future )
102106
103- @mark .filterwarnings ("ignore:.* was never awaited:RuntimeWarning" )
104- def declines_an_async_generator ():
105- async def some_async_generator ():
106- yield True # pragma: no cover
107+ assert await some_future is True
108+
109+ @mark .asyncio
110+ async def declines_an_async_generator ():
111+ async def some_async_generator_function ():
112+ yield True
113+
114+ some_async_generator = some_async_generator_function ()
115+
116+ assert not isawaitable (some_async_generator )
117+ assert not is_awaitable (some_async_generator )
107118
108- assert not isawaitable (some_async_generator ())
109- assert not is_awaitable (some_async_generator ())
119+ assert await some_async_generator .__anext__ () is True
0 commit comments