Skip to content

Commit

Permalink
Add failed test for #1093
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Aug 25, 2016
1 parent 81fbd19 commit 0a3862a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 4 additions & 4 deletions aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,24 @@ def new_func(self):


@contextlib.contextmanager
def loop_context():
def loop_context(loop_factory=asyncio.new_event_loop):
"""A contextmanager that creates an event_loop, for test purposes.
Handles the creation and cleanup of a test loop.
"""
loop = setup_test_loop()
loop = setup_test_loop(loop_factory)
yield loop
teardown_test_loop(loop)


def setup_test_loop():
def setup_test_loop(loop_factory=asyncio.new_event_loop):
"""Create and return an asyncio.BaseEventLoop
instance.
The caller should also call teardown_test_loop,
once they are done with the loop.
"""
loop = asyncio.new_event_loop()
loop = loop_factory()
asyncio.set_event_loop(None)
return loop

Expand Down
19 changes: 18 additions & 1 deletion tests/test_web_sendfile_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,31 @@
import aiohttp
from aiohttp import log, request, web
from aiohttp.file_sender import FileSender
from aiohttp.test_utils import unused_port
from aiohttp.test_utils import unused_port, loop_context

try:
import ssl
except:
ssl = False


try:
import uvloop
except:
uvloop = None


LOOP_FACTORIES = [asyncio.new_event_loop]
if uvloop:
LOOP_FACTORIES.append(uvloop.new_event_loop)


@pytest.yield_fixture(params=LOOP_FACTORIES)
def loop(request):
with loop_context(request.param) as loop:
yield loop


@pytest.fixture(params=['sendfile', 'fallback'], ids=['sendfile', 'fallback'])
def sender(request):
def maker(*args, **kwargs):
Expand Down

0 comments on commit 0a3862a

Please sign in to comment.