Skip to content

Commit

Permalink
fix async with in TestClient.ws_connect (#2528)
Browse files Browse the repository at this point in the history
* WIP fix#2525

* Update test_utils.py
  • Loading branch information
Christian Barra authored and asvetlov committed Nov 18, 2017
1 parent b39600f commit 278d5d5
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit 278d5d5

Please sign in to comment.