Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with simple example #25

Closed
catlee opened this issue May 31, 2016 · 7 comments
Closed

Help with simple example #25

catlee opened this issue May 31, 2016 · 7 comments
Assignees

Comments

@catlee
Copy link

catlee commented May 31, 2016

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.

@Tinche
Copy link
Member

Tinche commented May 31, 2016

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.

@Tinche Tinche self-assigned this May 31, 2016
@Tinche
Copy link
Member

Tinche commented May 31, 2016

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. 😕

@catlee
Copy link
Author

catlee commented May 31, 2016

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

@Tinche
Copy link
Member

Tinche commented May 31, 2016

Will be fixed tomorrow 👍 Thanks!

@Tinche
Copy link
Member

Tinche commented Jun 1, 2016

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

@catlee
Copy link
Author

catlee commented Jun 1, 2016

Yes, 0.4.1 works, thanks!

@Tinche
Copy link
Member

Tinche commented Jun 2, 2016

Great :)

@Tinche Tinche closed this as completed Jun 2, 2016
smagafurov pushed a commit to smagafurov/pytest-asyncio that referenced this issue Apr 4, 2018
smagafurov pushed a commit to smagafurov/pytest-asyncio that referenced this issue Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants