@@ -61,49 +61,59 @@ def some_generator():
61
61
assert not is_awaitable (some_generator ())
62
62
63
63
def declines_a_coroutine_function ():
64
- async def some_coroutine ():
64
+ async def some_async_function ():
65
65
return True # pragma: no cover
66
66
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 )
69
69
70
70
@mark .asyncio
71
- @mark .filterwarnings ("ignore:.* was never awaited:RuntimeWarning" )
72
71
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 )
75
79
76
- assert isawaitable (some_coroutine ())
77
- assert is_awaitable (some_coroutine ())
80
+ assert await some_coroutine is True
78
81
79
82
@mark .filterwarnings ("ignore::Warning" ) # Deprecation and Runtime warnings
80
83
@mark .skipif (
81
84
python_version >= (3 , 11 ),
82
85
reason = "Generator-based coroutines not supported any more since Python 3.11" ,
83
86
)
84
- def recognizes_an_old_style_coroutine (): # pragma: no cover
87
+ async def recognizes_an_old_style_coroutine (): # pragma: no cover
85
88
@asyncio .coroutine # type: ignore
86
- def some_old_style_coroutine ():
87
- yield False # pragma: no cover
89
+ def some_function ():
90
+ yield True
88
91
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 )
91
95
92
96
@mark .asyncio
93
- @mark .filterwarnings ("ignore:.* was never awaited:RuntimeWarning" )
94
97
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
97
100
98
- some_future = asyncio .ensure_future (some_coroutine ())
101
+ some_coroutine = some_async_function ()
102
+ some_future = asyncio .ensure_future (some_coroutine )
99
103
100
104
assert is_awaitable (some_future )
101
105
assert is_awaitable (some_future )
102
106
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 )
107
118
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