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

fix async with in TestClient.ws_connect #2528

Merged
merged 5 commits into from
Nov 18, 2017
Merged
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
12 changes: 9 additions & 3 deletions aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from yarl import URL

import aiohttp
from aiohttp.client import _RequestContextManager
from aiohttp.client import _RequestContextManager, _WSRequestContextManager

from . import ClientSession, hdrs
from .helpers import sentinel
Expand Down Expand Up @@ -278,13 +278,19 @@ def delete(self, path, *args, **kwargs):
self.request(hdrs.METH_DELETE, path, *args, **kwargs)
)

async def ws_connect(self, path, *args, **kwargs):
def ws_connect(self, path, *args, **kwargs):
"""Initiate websocket connection.

The api corresponds to aiohttp.ClientSession.ws_connect.

"""
ws = await self._session.ws_connect(
return _WSRequestContextManager(
self._ws_connect(path, *args, **kwargs)
)

@asyncio.coroutine
def _ws_connect(self, path, *args, **kwargs):
ws = yield from self._session.ws_connect(
self.make_url(path), *args, **kwargs)
self._websockets.append(ws)
return ws
Expand Down