From 8716fb4f46da6d77866a8ac63b244227c9824c27 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Sat, 4 Jun 2016 17:21:01 +0100 Subject: [PATCH 1/2] correct variable name in testing docs --- docs/testing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/testing.rst b/docs/testing.rst index 025cb6058af..2face4ede20 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -81,8 +81,8 @@ A pytest example could look like:: yield loop @pytest.fixture - def app(test_loop): - return create_app(event_loop) + def app(loop): + return create_app(loop) @pytest.yield_fixture From df5b4ea78169b4c9385fe5c0e9d1fd011e572a82 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Sat, 4 Jun 2016 17:54:49 +0100 Subject: [PATCH 2/2] more corrections and make TestClient.app public --- aiohttp/test_utils.py | 8 ++++---- docs/testing.rst | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py index 3d6b21cdcad..333c7d8ea41 100644 --- a/aiohttp/test_utils.py +++ b/aiohttp/test_utils.py @@ -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() @@ -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 diff --git a/docs/testing.rst b/docs/testing.rst index 2face4ede20..d62dd309882 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -73,7 +73,7 @@ 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(): @@ -87,7 +87,7 @@ A pytest example could look like:: @pytest.yield_fixture def test_client(app): - server = TestClient(app) + client = TestClient(app) yield client client.close()