From 8e5d508d676bb3971c22f049d1a46ac19c2c3d6b Mon Sep 17 00:00:00 2001 From: Alexey Popravka Date: Fri, 12 Aug 2016 13:25:12 +0300 Subject: [PATCH] fix test_client fixture to allow multiple clients per test --- aiohttp/pytest_plugin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aiohttp/pytest_plugin.py b/aiohttp/pytest_plugin.py index 5d9a8f5c378..0ac3f87d5e4 100644 --- a/aiohttp/pytest_plugin.py +++ b/aiohttp/pytest_plugin.py @@ -51,17 +51,17 @@ def loop(): @pytest.yield_fixture def test_client(loop): - client = None + clients = [] @asyncio.coroutine def _create_from_app_factory(app_factory, *args, **kwargs): - nonlocal client app = app_factory(loop, *args, **kwargs) client = TestClient(app) yield from client.start_server() + clients.append(client) return client yield _create_from_app_factory - if client: - client.close() + while clients: + clients.pop().close()