Closed
Description
I am running python 3.7.9 and pytest-asyncio 0.14.0 / pytest 6.2.1. When I run the following code in pytest, I get an error thrown even though the test passes.
$>pytest -vv test.py --log-cli-level=DEBUG
test.py
import pytest
@pytest.mark.asyncio
async def test_generator_limit():
async def gen():
yield 1
yield 2
yield 3
yield 4
async for res in gen():
if res == 2:
break
ERROR asyncio:base_events.py:1619 Task was destroyed but it is pending! task: <Task pending coro=<<async_generator_athrow without __name__>()>>
If I run this code as a script, I get no such error
import asyncio
async def test_generator_limit():
async def gen():
yield 1
yield 2
yield 3
yield 4
async for res in gen():
if res == 2:
break
asyncio.run(test_generator_limit(), debug=True)
(NOTE: the value of debug
does not change the results)
This error only shows up when I introduce the break
. According to PEP 525 this appears to be valid async code.
Metadata
Metadata
Assignees
Labels
No labels