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

No warning on skip in asyncio #126

Merged
merged 3 commits into from Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions pytest_asyncio/plugin.py
Expand Up @@ -140,9 +140,16 @@ def wrap_in_sync(func):
def inner(**kwargs):
coro = func(**kwargs)
if coro is not None:
future = asyncio.ensure_future(coro)
asyncio.get_event_loop().run_until_complete(future)

task = asyncio.ensure_future(coro)
try:
asyncio.get_event_loop().run_until_complete(task)
except BaseException:
# run_until_complete doesn't get the result from exceptions
# that are not subclasses of `Exception`. Consume all
# exceptions to prevent asyncio's warning from logging.
if task.done():
jcrist marked this conversation as resolved.
Show resolved Hide resolved
task.exception()
raise
return inner


Expand Down
5 changes: 5 additions & 0 deletions tests/test_simple.py
Expand Up @@ -134,3 +134,8 @@ async def test_asyncio_marker_without_loop(self, remove_loop):
"""Test the asyncio pytest marker in a Test class."""
ret = await async_coro()
assert ret == 'ok'


@pytest.mark.asyncio
async def test_no_warning_on_skip():
pytest.skip("Test a skip error inside asyncio")