Skip to content

Commit

Permalink
correct variable name in testing docs (#913)
Browse files Browse the repository at this point in the history
* correct variable name in testing docs

* more corrections and make TestClient.app public
  • Loading branch information
samuelcolvin authored and asvetlov committed Jun 4, 2016
1 parent fc2b408 commit 3347cdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,16 @@ class TestClient:
:type app: aiohttp.web.Application
:param protocol: the aiohttp.web application passed to create_test_server
:param protocol: http or https
:type app: aiohttp.web.Application
:type protocol: str
TestClient can also be used as a contextmanager, returning
the instance of itself instantiated.
"""

def __init__(self, app, protocol="http"):
self._app = app
self.app = app
self._loop = loop = app.loop
self.port = unused_port()
self._handler = handler = app.make_handler()
Expand Down Expand Up @@ -418,7 +418,7 @@ def close(self):
loop = self._loop
loop.run_until_complete(self._session.close())
loop.run_until_complete(self._handler.finish_connections())
loop.run_until_complete(self._app.finish())
loop.run_until_complete(self.app.finish())
self._server.close()
loop.run_until_complete(self._server.wait_closed())
self._closed = True
Expand Down
8 changes: 4 additions & 4 deletions docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ Pytest example
A pytest example could look like::

# assuming you are using pytest-asyncio
from asyncio.test_utils import TestClient, loop_context
from aiohttp.test_utils import TestClient, loop_context

@pytest.yield_fixture
def loop():
with loop_context() as loop:
yield loop

@pytest.fixture
def app(test_loop):
return create_app(event_loop)
def app(loop):
return create_app(loop)


@pytest.yield_fixture
def test_client(app):
server = TestClient(app)
client = TestClient(app)
yield client
client.close()

Expand Down

0 comments on commit 3347cdc

Please sign in to comment.