pytest-dev/pytest-asyncio

Help with simple example

catlee opened this issue · 7 comments

I'm sure I'm doing something wrong, but I can't get tests working with pytest.mark.asyncio.

import pytest

@pytest.mark.asyncio
async def test_foo():
    assert False

Running py.test claims that test_foo was executed and passed.

Using pytest 2.9.2, pytest-asyncio 0.4.0.

I don't have access to a desktop computer right now but I think I might know what's causing this. Thanks for reporting, will look into it asap.

If I'm right the test is being executed (you can verify with a print inside and running pytest with -s), just the assert exceptions are being swallowed. 😕

Yes, you're right. Here's the updated code:

import pytest

@pytest.mark.asyncio
async def test_foo():
    print('hello')
    assert False
    print('world')

And the output from py.test test_foo.py -s -v:

===================================================== test session starts =====================================================
platform linux -- Python 3.5.1+, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- /home/catlee/test/pytest-async/bin/python3.5
cachedir: .cache
rootdir: /home/catlee/test/pytest-async, inifile: 
plugins: asyncio-0.4.0
collected 1 items 

test_foo.py::test_foo hello
PASSED

Will be fixed tomorrow 👍 Thanks!

Hi, I've just pushed 0.4.1 to PyPI. Can you confirm it fixes the issue for you?

Yes, 0.4.1 works, thanks!

Great :)