(pytester: Pytester)
| 1257 | |
| 1258 | |
| 1259 | def 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 | |
| 1287 | def test_error_on_async_gen_function(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected