MCPcopy
hub / github.com/pytest-dev/pytest / test_error_on_async_function

Function test_error_on_async_function

testing/acceptance_test.py:1259–1284  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1257
1258
1259def test_error_on_async_function(pytester: Pytester) -> None:
1260 # In the below we .close() the coroutine only to avoid
1261 # "RuntimeWarning: coroutine 'test_2' was never awaited"
1262 # which messes with other tests.
1263 pytester.makepyfile(
1264 test_async="""
1265 async def test_1():
1266 pass
1267 async def test_2():
1268 pass
1269 def test_3():
1270 coro = test_2()
1271 coro.close()
1272 return coro
1273 """
1274 )
1275 result = pytester.runpytest()
1276 result.stdout.fnmatch_lines(
1277 [
1278 "*async def functions are not natively supported*",
1279 "*test_async.py::test_1*",
1280 "*test_async.py::test_2*",
1281 "*test_async.py::test_3*",
1282 ]
1283 )
1284 result.assert_outcomes(failed=3)
1285
1286
1287def test_error_on_async_gen_function(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
assert_outcomesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected