Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
get rid of wait_for in conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
popravich committed Jan 16, 2017
1 parent 844f97c commit cb5aabb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import tempfile

from collections import namedtuple
from async_timeout import timeout as async_timeout

import aioredis
import aioredis.sentinel
Expand Down Expand Up @@ -479,13 +480,20 @@ def pytest_pyfunc_call(pyfuncitem):
loop = funcargs['loop']
testargs = {arg: funcargs[arg]
for arg in pyfuncitem._fixtureinfo.argnames}

loop.run_until_complete(
asyncio.wait_for(pyfuncitem.obj(**testargs),
marker.kwargs.get('timeout', 15),
loop=loop))
_wait_coro(pyfuncitem.obj, testargs,
timeout=marker.kwargs.get('timeout', 1),
loop=loop))
return True


@asyncio.coroutine
def _wait_coro(corofunc, kwargs, timeout, loop):
with async_timeout(timeout, loop=loop):
return (yield from corofunc(**kwargs))


def pytest_runtest_setup(item):
if 'run_loop' in item.keywords and 'loop' not in item.fixturenames:
# inject an event loop fixture for all async tests
Expand Down

0 comments on commit cb5aabb

Please sign in to comment.