I'm trying to test a async Python function using pytest. My test is passing with a warning, when it should be failing.
This is my test:
import asynctest
import pytest
from Foo.bar import posts
@pytest.mark.asyncio
async def test_get_post_exists():
returned_post = await posts.get_post('0')
assert returned_post.id == 0
assert returned_post.text == 'Text for the post body.'
assert True == False
It passes with the following message:
================================== test session starts ===================================
platform darwin -- Python 3.6.4, pytest-3.4.2, py-1.5.2, pluggy-0.6.0
rootdir: /path/path/path/path, inifile:
collected 1 item
tests/unit/route_logic/test_post_helpers.py . [100%]
==================================== warnings summary ====================================
tests/unit/route_logic/test_post_helpers.py::test_get_post_exists
/usr/local/lib/python3.6/site-packages/_pytest/python.py:155: RuntimeWarning: coroutine 'test_get_post_exists' was never awaited
testfunction(**testargs)
-- Docs: http://doc.pytest.org/en/latest/warnings.html
========================== 1 passed, 1 warnings in 0.10 seconds ==========================