Skip to content

Commit

Permalink
Merge pull request #1072 from KeepSafe/pytest_plugin
Browse files Browse the repository at this point in the history
Fix test_client fixture to allow multiple clients per test
  • Loading branch information
popravich authored Aug 13, 2016
2 parents 10e3a36 + 8e5d508 commit 8131cae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aiohttp/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 8131cae

Please sign in to comment.