Closed
Description
I'd like pytest to fail on "coroutine never awaited" RuntimeWarning. But something about these warnings cause pytest not to behave as expected: a matching -W
spec actually causes the warning to be completely ignored.
I suspect it's because these warnings are issued on shutdown of the interpreter, after the pytest harness has exited.
def test_foo():
async def bar():
assert False
bar()
$ pytest foo.py
====================================== test session starts ======================================
platform darwin -- Python 3.7.7, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
collected 1 item
foo.py . [100%]
======================================= warnings summary ========================================
foo.py::test_foo
foo.py:5: RuntimeWarning: coroutine 'test_foo.<locals>.bar' was never awaited
bar()
-- Docs: https://docs.pytest.org/en/stable/warnings.html
================================= 1 passed, 1 warning in 0.02s ==================================
$ pytest -Werror foo.py
====================================== test session starts ======================================
platform darwin -- Python 3.7.7, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
collected 1 item
foo.py . [100%]
======================================= 1 passed in 0.04s =======================================
Metadata
Metadata
Assignees
Labels
No labels