@@ -146,27 +146,30 @@ def pytest_configure(config):
146
146
)
147
147
148
148
149
- @ hookimpl ( trylast = True )
150
- def pytest_pyfunc_call ( pyfuncitem ):
151
- def async_warn ():
152
- msg = "async def functions are not natively supported and have been skipped. \n "
153
- msg += "You need to install a suitable plugin for your async framework, for example: \n "
154
- msg += " - pytest-asyncio\n "
155
- msg += " - pytest-trio\n "
156
- msg += " - pytest-tornasync"
157
- warnings .warn (PytestUnhandledCoroutineWarning (msg .format (pyfuncitem . nodeid )))
158
- skip (msg = "async def function and no async plugin installed (see warnings)" )
149
+ def async_warn ( nodeid : str ) -> None :
150
+ msg = "async def functions are not natively supported and have been skipped. \n "
151
+ msg += (
152
+ "You need to install a suitable plugin for your async framework, for example: \n "
153
+ )
154
+ msg += " - pytest-asyncio\n "
155
+ msg += " - pytest-trio\n "
156
+ msg += " - pytest-tornasync"
157
+ warnings .warn (PytestUnhandledCoroutineWarning (msg .format (nodeid )))
158
+ skip (msg = "async def function and no async plugin installed (see warnings)" )
159
159
160
+
161
+ @hookimpl (trylast = True )
162
+ def pytest_pyfunc_call (pyfuncitem : "Function" ):
160
163
testfunction = pyfuncitem .obj
161
164
if iscoroutinefunction (testfunction ) or (
162
165
sys .version_info >= (3 , 6 ) and inspect .isasyncgenfunction (testfunction )
163
166
):
164
- async_warn ()
167
+ async_warn (pyfuncitem . nodeid )
165
168
funcargs = pyfuncitem .funcargs
166
169
testargs = {arg : funcargs [arg ] for arg in pyfuncitem ._fixtureinfo .argnames }
167
170
result = testfunction (** testargs )
168
171
if hasattr (result , "__await__" ) or hasattr (result , "__aiter__" ):
169
- async_warn ()
172
+ async_warn (pyfuncitem . nodeid )
170
173
return True
171
174
172
175
0 commit comments