Skip to content

Commit

Permalink
Issue 1069/document explicit loop for tests (#1109)
Browse files Browse the repository at this point in the history
* Added args example in explicit loop testing docs

Before only loop was being passed to the constructor example.
If the service required args, the example would fail. With the new example,
any args and kwargs received from the calling service will be passed
correctly to the tested service

* Modified writing testable service section for consistency
  • Loading branch information
argaen authored and asvetlov committed Aug 23, 2016
1 parent ee1532c commit 96f5415
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ in its signature. An example would be the following::
class TestAcceptance:

async def test_get(self, test_client, loop):
with patch("main.AioESService", MagicMock(return_value=AioESService(loop=loop))):
with patch("main.AioESService", MagicMock(
side_effect=lambda *args, **kwargs: AioESService(*args, **kwargs, loop=loop))):
client = await test_client(create_app)
resp = await client.get("/")
assert resp.status == 200
Expand Down

0 comments on commit 96f5415

Please sign in to comment.