Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion pytest_asyncio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ def pytest_pyfunc_call(pyfuncitem):
funcargs = pyfuncitem.funcargs
testargs = {arg: funcargs[arg]
for arg in pyfuncitem._fixtureinfo.argnames}
test_coroutine = pyfuncitem.obj(**testargs)

if 'timeout' in pyfuncitem.keywords[marker_name].kwargs:
timeout = pyfuncitem.keywords[marker_name].kwargs['timeout']
test_coroutine = asyncio.wait_for(test_coroutine, timeout=timeout)

try:
event_loop.run_until_complete(
asyncio.async(pyfuncitem.obj(**testargs), loop=event_loop))
asyncio.async(test_coroutine, loop=event_loop))
return True
finally:
if forbid_global_loop:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def test_asyncio_process_pool_marker(event_loop):
assert ret == 'ok'


@pytest.mark.xfail(raises=asyncio.TimeoutError)
@pytest.mark.asyncio(timeout=0.05)
def test_asyncio_marker_fail():
yield from asyncio.sleep(0.1)


@pytest.mark.asyncio
def test_unused_port_fixture(unused_tcp_port, event_loop):
"""Test the unused TCP port fixture."""
Expand Down