Skip to content

Commit

Permalink
fixes #2717 Makes unittest example work (#2718)
Browse files Browse the repository at this point in the history
  • Loading branch information
timhughes authored and asvetlov committed Feb 11, 2018
1 parent 308e779 commit ad4af93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/2717.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue with unittest example not compiling in testing docs.
13 changes: 9 additions & 4 deletions docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ functionality, the AioHTTPTestCase is provided::
"""
Override the get_app method to return your application.
"""
return web.Application()
async def hello(request):
return web.Response(text='Hello, world')

app = web.Application()
app.router.add_get('/', hello)
return app

# the unittest_run_loop decorator can be used in tandem with
# the AioHTTPTestCase to simplify running
Expand All @@ -259,10 +264,10 @@ functionality, the AioHTTPTestCase is provided::
assert "Hello, world" in text

# a vanilla example
def test_example(self):
def test_example_vanilla(self):
async def test_get_route():
url = root + "/"
resp = await self.client.request("GET", url, loop=loop)
url = "/"
resp = await self.client.request("GET", url)
assert resp.status == 200
text = await resp.text()
assert "Hello, world" in text
Expand Down

0 comments on commit ad4af93

Please sign in to comment.