Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pytest_asyncio/plugin.py
Original file line number Diff line number Diff line change
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():
task.exception()
raise
return inner


Expand Down
5 changes: 5 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
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("Need a skip error inside asyncio")