Async fixture with autouse=True
not executing properly in test
#518
Labels
autouse=True
not executing properly in test
#518
pip list
from the virtual environment you are usingDescription:
When using an asyncio fixture with pytest, the teardown fixture is not executing properly. The teardown fixture is meant to run after
test_foo
and print "teardown", then await for one second before finishing. However, when the yield statement is included in the fixture, nothing gets printed to the console. If the yield statement is removed, nothing still gets printed but I get a warning: "RuntimeWarning: coroutine 'teardown' was never awaited". I don't understand this behaviour, can someone help me understand?Steps to reproduce:
run
pytest test_foo.py -s
Expected result:
The teardown fixture should run after the test function, print "teardown", and await for one second before finishing.
Actual result:
If the yield statement is included, "teardown" does not get printed.
If the yield statement is removed, "teardown" does still not get print but I get a warning:
"RuntimeWarning: coroutine 'teardown' was never awaited".
Environment:
Python version: 3.11.0
Pytest version: 7.2.0
Operating system: Mac OS 13.2.1
Pip list:
Package Version
attrs 22.2.0
iniconfig 2.0.0
maturin 0.14.12
packaging 23.0
pip 22.3
pluggy 1.0.0
pydantic 1.10.2
pyo3-asyncio-example 0.1.0
pytest 7.2.0
pytest-asyncio 0.20.3
python-dotenv 0.19.1
setuptools 65.5.0
typing_extensions 4.4.0
The text was updated successfully, but these errors were encountered: